SHARE
TWEET

Untitled

a guest Jan 18th, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.  
  9.     int n;
  10.     cin>>n;
  11. for(int i=1;i<n;i++){
  12.     int p=i*i;
  13.     int c=p*i;
  14.      bool  ok=false;
  15.  
  16.         while(p !=0 && !ok ){
  17.                 int cp_digit = p % 10;
  18.                 while(c !=0){
  19.                         int cc_digit = c %10;
  20.                         c=c/10;
  21.                 p=p/10;
  22.                 if(cp_digit== cc_digit){
  23.                     ok=true;
  24.                     break;
  25.                 }
  26.         }
  27.          }   if(ok==true){
  28.                 cout<<i<<p<<c<<endl;
  29.  
  30.     }
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.     return 0;
  42.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top