Discussion:simply use brute force.
#include<bits/stdc++.h>
using namespace std;
int power(int n,int m){
int crisis,i;
std::vector<int> vec;
for(i=1;i<=n;i++)
{
vec.push_back(i);
}
i=0;
while(vec[i]!=13)
{
vec.erase(vec.begin()+i);
i+=m-1;
if(i>=vec.size())
i=i%vec.size();
}
if(vec.size()==1)
return true;
return false;
}
int main(){
int n,i,m;
while(cin >>n&&n)
{
m=1;
while(!power(n,m))
m++;
cout <<m<<endl;
}
return 0;
}
No comments:
Post a Comment