#29926:


99980001 (207-07張讓宸)

學校 : 臺北市私立延平高級中學
編號 : 128504
來源 : [203.72.178.2]
最後登入時間 :
2024-10-22 10:35:11
d182. 00256 - Quirksome Squares -- UVa256 | From: [203.72.178.1] | 發表日期 : 2022-04-12 17:26

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==2){
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					if(i*10+j==pow((i+j),2)){
						cout<<i<<j<<endl;
					}
				}
			}
		}
		else if(n==4){
				for(int i=0;i<100;i++){
				for(int j=0;j<100;j++){
					if(i*100+j==pow((i+j),2)){
						if(i<10 and j<10){
							cout<<"0"<<i<<"0"<<j<<endl;	
						}
						else if(i>=10 and j<10){
							cout<<i<<"0"<<j<<endl;
						}
						else if(i<10 and j>=10){
							cout<<"0"<<i<<j<<endl;
						}
						else cout<<i<<j<<endl;
					}
				}
			}
		}
		else if(n==6){
			for(int i=0;i<1000;i++){
				for(int j=0;j<1000;j++){
					if(i*1000+j==pow((i+j),2)){
						if(i<10 and j<10){
							cout<<"00"<<i<<"00"<<j<<endl;	
						}
						else if(i>=10 and i<100 and j<10){
							cout<<"0"<<i<<"00"<<j<<endl;
						}
						else if(i<10 and j<100 and j>=10){
							cout<<"00"<<i<<"0"<<j<<endl;
						}
						else if(i>=10 and i<100 and j>=10 and j<100){
							cout<<"0"<<i<<"0"<<j<<endl;
						}
						else if(i>=10 and i<100 and j>=100){
							cout<<"0"<<i<<j<<endl;
						}
						else if(i>=100 and j<100 and j>=10){
							cout<<i<<"0"<<j<<endl;
						} 
						else if(i>=100 and j<10){
							cout<<i<<"00"<<j<<endl;
						}
						else if(i<10 and j>=100){
							cout<<"00"<<i<<j<<endl;
						}
						else cout<<i<<j<<endl;
					}
				}
			}
		}
		else if(n==8){
			for(int i=0;i<10000;i++){
				for(int j=0;j<10000;j++){
					if(i*10000+j==pow((i+j),2)){
						if(i<10 and j<10){
							cout<<"000"<<i<<"000"<<j<<endl;	
						}
						else if(i>=10 and i<100 and j<10){
							cout<<"00"<<i<<"000"<<j<<endl;
						}
						else if(i<10 and j<100 and j>=10){
							cout<<"000"<<i<<"00"<<j<<endl;
						}
						else if(i>=10 and i<100 and j>=10 and j<100){
							cout<<"00"<<i<<"00"<<j<<endl;
						}
						else if(i>=10 and i<100 and j>=100){
							cout<<"00"<<i<<"0"<<j<<endl;
						}
						else if(i>=100 and j<100 and j>=10){
							cout<<"0"<<i<<"00"<<j<<endl;
						} 
						else if(i>=100 and i<1000 and j>=100 and j<1000){
							cout<<"0"<<i<<"0"<<j<<endl;
						}
						else if(i>=100 and i<1000 and j>=1000){
							cout<<"0"<<i<<j<<endl;
						}
						else if(i>=1000 and j<1000 and j>=100){
							cout<<i<<"0"<<j<<endl;
						}
						else if(i<10 and j>=1000){
							cout<<"000"<<i<<j<<endl;
						}
						else if(i>=1000 and j<10){
							cout<<i<<"000"<<j<<endl;
						}
			            else if(i<1000 and i>=100 and j<10){
			            	cout<<"0"<<i<<"000"<<j<<endl;
						}
						else if(i<10 and j>=100 and j<1000){
							cout<<"000"<<i<<"0"<<j<<endl;
						}
						else cout<<i<<j<<endl;
					}
				}
			}
		}
		
	}
}
 
ZeroJudge Forum