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 |
我的程序没考虑什么第64位,AC了#include"iostream" #include"stdio.h" #include"algorithm" using namespace std; int main(){ int m; cin>>m; while(m--){ int n; cin>>n; int i; char c[65]; cin>>c; int p[64]; for(i=0;i<n;i++) if(c[i]=='p') p[i]=1; else p[i]=-1; long long a; scanf("%I64d",&a); reverse(c,c+n); reverse(p,p+n); int b[64]; for(i=0;i<n;i++){ if(abs(a)%2==1) b[i]=1; else b[i]=0; a=a-b[i]*p[i]; a/=2; } if(a==0){ for(i=n-1;i>=0;i--) cout<<b[i]; cout<<endl; } else cout<<"Impossible\n"; } system("pause"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator