您的位置:首页 > 其它

POJ 1012 Joseph 笔记 G++

2017-04-21 18:27 411 查看
/*
#include <iostream>
#include <vector>
using namespace std;
//Time Limit Exceeded
int main()
{
while(1)
{
int NUM;
cin>>NUM;
if(NUM==0)
{
break;
}
int shu=1;
while(1)
{
int t=shu;
int wz=0;
vector<int> a;
for(int i=0;i<NUM;i++)
{
a.push_back(1);
}
for(int i=0;i<NUM;i++)//把2挑出来
{
a.push_back(2);
}
int N=NUM*2;
for(int i=0;i<NUM;i++)
{
//cout<<"shu "<<shu<<" wz "<<wz<<" N "<<N<<" (wz+shu-1)%N "<<(wz+shu-1)%N-1<<endl;
if(a[(wz+shu-1)%N]==2)
{
a.erase(a.begin()+(wz+shu-1)%N);
wz=(wz+shu-1)%N;
N--;
}else
{
shu++;
break;
}
}
if(shu==t)
{
cout<<shu<<endl;
break;
}
}
}
return 0;
}
*/
//由上面程序的结果打表
#include <iostream>
using namespace std;
int a[14];
int main()
{
a[1]=2;
a[2]=7;
a[3]=5;
a[4]=30;
a[5]=169;
a[6]=441;
a[7]=1872;
a[8]=7632;
a[9]=1740;
a[10]=93313;
a[11]=459901;
a[12]=1358657;
a[13]=2504881;
while(1)
{
int NUM;
cin>>NUM;
if(NUM==0)
{
break;
}
cout<<a[NUM]<<endl;
}
return 0;
}




k个好人k个坏人,好人在前,围成一圈。按一个数查圈,先挑出坏人。求这个数。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: