Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:实在看不出来代码哪里还有问题了,总是WA..........

Posted by 660345 at 2010-09-12 10:27:54 on Problem 1023
In Reply To:实在看不出来代码哪里还有问题了,总是WA.......... Posted by:buaaGG at 2009-12-21 21:34:28
> #include <cstdio>
> #include <iostream>
> using namespace std;
> 
> int main(){
>     int t, k, i;
>     char s[65];
>     long long n;
>     bool possible;
>     scanf("%d", &t);
>     while (t--){
>         scanf("%d", &k);
>         scanf("%s", s);
> //        scanf("%lld", &n);
>         cin >> n;
>         possible = 1;
>         if (s[0] == 'p' && n < 0) possible = 0;
>         if (s[0] == 'n' && n > 0) possible = 0;
>         for (i = k-1; i >= 0; i--){
>             if (n & (1LL << (k - i - 1))){
>                 if (s[i] == 'p') n -= (1LL << (k - i - 1));
>                 else n += (1LL << (k - i - 1));
>                 s[i] = '1';
>             }    
>             else{
>                 s[i] = '0';
>             }
>         }    
>         if (n != 0) possible = 0;
>         printf("%s\n", possible ? s : "Impossible");
>     }    
> }
>      

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator