| ||||||||||
| 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 | |||||||||
帮小弟看看这个算法是否可行,为什么总是WA呢#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int k;
cin>>k;
char f[k+1];
cin>>f;
long long n;
cin>>n;
bool o[k];
long long bign=0;
for(int i=0;i<k;i++)
{
if(f[i]=='p')
{
bign+=(long long)(1<<(k-i-1));
o[i]=true;
}else
o[i]=false;
}
if(bign<n)
{
cout<<"Impossible";
goto ending;
}
bign=bign-n;
for(int i=0;i<k;i++)
{
if((long long)(bign&(long long)(1<<(k-i-1)))!=0)
o[i]=!o[i];
cout<<o[i];
}
ending:
cout<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator