614A-Link/Cut Tree
比较水,注意64位int仍然可能溢出。
#include <cstdio> #include <algorithm> #include <cstring> using namespace std; typedef unsigned long long int LL; LL l,r; int k; int main() { scanf("%I64d %I64d %d",&l,&r,&k); int cnt = 0; LL pow = 1; int i = 0; while(true) { if(pow <=r && pow >=l) { printf("%s%I64d",cnt?" ":"",pow); cnt++; } i++; if(pow > r) break; if(r/k < pow) break; pow *= k; } if(cnt == 0) printf("-1 "); }
614B-Gena's Code
很水,统计0的个数就好了
区分beautiful和非beautiful数。
#include <cstdio> #include <cstring> using namespace std; int N,n0; char unbtf[100100]; int main() { scanf("%d",&N); int flag_unb = 0; int flag_0 = 0; getchar(); for(int i=0;i<N;i++) { char c; int cnt = 0,flag = 1,tmp0 = 0; while((c=getchar()) && c>='0' && c<='9') { if(!flag_unb) unbtf[cnt] = c; if((c!='0'&&cnt!=0) || (c!='1'&&c!='0'&&cnt==0)) { flag = 0; } if(c == '0') tmp0++; cnt++; } if(!flag_unb) unbtf[cnt] = '