80分WA,求助5555
查看原帖
80分WA,求助5555
123168
王宏宇11楼主2021/11/23 16:54
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long n,m,k;
string ss;
string gl(int n,int now,string s)
   {if(n==0) return s;
    else if(n==1)
      {if(now==1) return s+"0";
       else if(now==2) return s+"1";
	  }
	else if(n>1)
	   {if(now>pow(2,n-1))
	       {if(now<=3*pow(2,n-2))
	          {now=now+2*(3*pow(2,n-2)-now)+1;
			   return gl(n-1,now-pow(2,n-1),s+"1");
			  }
			else if(now>3*pow(2,n-2))
			    {now=now-2*(now-3*pow(2,n-2))+1;
			    return gl(n-1,now-pow(2,n-1),s+"1");
				}
		   }
		else if(now<=pow(2,n-1)) return gl(n-1,now,s+"0");
	   }
  return s;
   }
int main()
{//cout<<ss<<"\n"; 
scanf("%lld%lld",&n,&k);
ss=gl(n,k+1,ss);
cout<<ss;
return 0;
}

样例三就会全爆0,提交是80分,这是为什么呀

2021/11/23 16:54
加载中...