Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- for(int i=1;i<n;i++){
- int p=i*i;
- int c=p*i;
- bool ok=false;
- while(p !=0 && !ok ){
- int cp_digit = p % 10;
- while(c !=0){
- int cc_digit = c %10;
- c=c/10;
- p=p/10;
- if(cp_digit== cc_digit){
- ok=true;
- break;
- }
- }
- } if(ok==true){
- cout<<i<<p<<c<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement