Pabon_SEC

Very Big Perfect Squares

May 28th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. string s;
  6.  
  7. int main()
  8. {
  9.     int len,i,num_of_zero,num,ans;
  10.  
  11.     while(cin>>s)
  12.     {
  13.         if(s[0]=='0')
  14.             break;
  15.  
  16.         len = s.length();
  17.  
  18.         if(len%2)
  19.         {
  20.             num = s[0]-48;
  21.  
  22.             num_of_zero = len/2;
  23.         }
  24.         else
  25.         {
  26.             num_of_zero = (len-2)/2;
  27.  
  28.             num = (s[0]-48)*10+(s[1]-48);
  29.         }
  30.  
  31.         ans = sqrt(num);
  32.  
  33.         cout<<ans;
  34.  
  35.         for(i=1; i<=num_of_zero; i++)
  36.         {
  37.             cout<<0;
  38.         }
  39.  
  40.         cout<<endl;
  41.     }
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment