uva575: There's nothing to say about this problem.
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6#include <string>7#include <cctype>8#include <vector>9#include <map>Ten using namespacestd; One Const intmaxn= +; A strings; - intA[MAXN]; - intMain () the { - Long Longsum; - while(cin>>s) - { + if(s[0]=='0') - Break; +sum=0; AMemset (A,0,sizeof(a)); at for(intI=0; I<s.length (); i++) -A[s.length ()-i-1]=s[i]-'0'; - for(intI=0; I<s.length (); i++) -sum+=a[i]* (POW (2, i+1)-1); -cout<<sum<<Endl; - } in return 0; -}
View Code
UVA10110:
This topic considers the factor of the last number, if is even is closed, odd is open, it is obvious that the general number is even, only one case, is the total square number of time is odd, so judge
SQRT (n) *sqrt (n) is equal to n
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5 using namespacestd;6 Long LongN;7 voidjudge ()8 {9 Long Longb=sqrt (n);Ten if(b*b==N) Onecout<<"Yes"<<Endl; A Else -cout<<"No"<<Endl; - } the intMain () - { - while(cin>>N) - { + if(n==0) - Break; + judge (); A } at return 0; -}
View Code
Basic math problems in the introductory classic of algorithmic competition