Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. unsigned long long sq (unsigned long long a) {
  5.         unsigned long long res = 0;
  6.         for (unsigned long long i = 0;  i < sqrt(a) ;++i){
  7.             if (i*i>=ceil(a/2.0) && a > 4){
  8.                 break;
  9.             }
  10.             unsigned long long c = a-i*i;
  11.             if ((unsigned long long)(sqrt(c)) == sqrt(c)){
  12.             ++res;
  13.             //cout<<"  a  :  "<<a<<" |  square  : "<<i*i<<endl;
  14.             }
  15.         }
  16.         return res;  
  17.     }  
  18.  
  19.  
  20. int main () {
  21.     char a [25];
  22.     while(scanf("%s",a)!= EOF) {
  23.         unsigned long long product = 1;
  24.         for (int i = 0; i < strlen(a);++i)
  25.         if (a[i] > '1')
  26.         product *= a[i]-'0';
  27.         printf("%llu\n",sq(product));
  28.         delete(a);
  29.     }  
  30. }