Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
DP了我一整天,才发现开不了这2^64这么大的数组,给个更短的.In Reply To:我的程序没考虑什么第64位,AC了 Posted by:hakky at 2008-12-07 23:07:58 #include <iostream> using namespace std; #define MAX_K 65 char np[MAX_K]; int b[MAX_K]; int T,K; long long int N; int main() { scanf("%d",&T); while(T--) { scanf("%d",&K); scanf("%s",np); scanf("%lld",&N); for(int i=K-1;i>=0;i--) { if(abs(N)%2) { b[i]=1; if(np[i]=='n') N+=1; else N-=1; }else{ b[i]=0; } N/=2; } if(N) printf("Impossible\n"); else { for(int i=0;i<=K-1;i++) printf("%d",b[i]); printf("\n"); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator