Topcoder SRM 619 DIv2 500 --又是耻辱的一题

这题明明是一个简单的类似约瑟夫环的问题,但是由于细节问题迟迟不能得到正确结果,结果比赛完几分钟才改对。。耻辱。

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
#define NN 370000 class ChooseTheBestOne
{
private:
public:
ll calc3(int n)
{
return (ll)pow(n,);
}
int countNumber(int N)
{
ll now = ,remain = (ll)(N-);
ll rd = ;
ll pos;
int has[];
memset(has,-,sizeof(has));
has[] = ;
while(rd < N)
{
while(has[now] == )
{
now = (now+)%N;
}
ll call = calc3(rd);
ll add = (call-)%remain;
ll k = ;
for(pos=now;k<add;)
{
pos = (pos+)%N;
if(has[pos] != )
k++;
}
has[pos] = ;
now = (pos+)%N;
//cout<<"出去: "<<pos+1<<" 现在"<<now+1<<endl;
remain--;
rd++; }
ll i;
for(i=;i<N;i++)
{
if(has[i] == -)
{
return i+;
}
}
}
}; int main()
{
ChooseTheBestOne *kc = new ChooseTheBestOne();
cout<<(*kc).countNumber()<<endl;
return ;
}
上一篇:Photoshop创建原汁原味的泥土字体


下一篇:LR常用函数以及调用自定义函数