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 |
偶在ZJU过了, 为什么在这儿WA?这里G++不支持long long int么? #include <cstdio> int main() { int t,i,j,k,sign,pos; char pn[64],num[64]; long long int N; scanf("%d\n", &t); for (i=0; i<t; i++) { scanf("%d\n", &k); scanf("%s\n", pn); scanf("%lld\n", &N); pos=0; if (N>0) sign=1; else sign=-1; for (j=k-1; j>=0; j--) { if (pn[j]=='p') { num[pos]=sign*(N%2); N = (N-num[pos])/2; pos++; } else { num[pos]=sign*(N%2); N = (N+num[pos])/2; pos++; } } if (N!=0) {printf("Impossible\n"); continue;} for (j=pos-1; j>=0; j--) { printf("%d",num[j]); } printf("\n"); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator