提交时间:2023-02-02 22:41:39

运行 ID: 7267

#include<iostream> using namespace std; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ if(i*i<10){ cout<<i<<" "<<i*i<<endl; } else if(i*i<100&&i*i>=10&&i*i/10==i*i%10){ cout<<i<<" "<<i*i<<endl; } else if(i*i<1000&&i*i>=100&&i*i/100==i*i%10){ cout<<i<<" "<<i*i<<endl; } else if(i*i<10000&&i*i>=1000&&i*i/1000==i*i%10&&i*i/100-i*i/1000*10==i*i/10-i*i/100*10){ cout<<i<<" "<<i*i<<endl; } else if(i*i>=10000&&i*i/10000==i*i%10&&i*i/10-i*i/100*10==i*i/1000-i*i/10000*10){ cout<<i<<" "<<i*i<<endl; } } return 0; }