CCF-CSP-2017-12-2游戏
题目链接:http://118.190.20.162/view.page?gpid=T67
思路:模拟,可以用过队列来模拟环
代码:
#include<bits/stdc++.h>
using namespace std;
queue<int> qu;
int n,k;
bool check(int x){
if(x%k==0)return true;
if(x%10==k)return true;
return false;
}
int main (){
cin>>n>>k;
for(int i=1;i<=n;i++)
qu.push(i);
int num=1;
while(qu.size()>1){
if(check(num)){
qu.pop();
}
else {
qu.push(qu.front());
qu.pop();
}
num++;
}
cout<<qu.front();
return 0;
}

浙公网安备 33010602011771号