您的位置:首页 > 其它

CSP认证考试201712-B 游戏

2018-01-14 12:07 288 查看
代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cctype>
#include <fstream>
#define INF 0x3f3f3f3f
#define EPS 1e-24
using namespace std;

typedef long long ll;
const ll Mod = 1e9 + 7;

int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);

int n,k;
while(cin>>n>>k){
queue<int> que;
for(int i=1;i<=n;i++)que.push(i);
int num = 1;
while(que.size()>1){
int tmp = que.front();
que.pop();
if(num%10 != k && num%k != 0){
que.push(tmp);
}
num++;
}
int ans = que.front();
cout<< ans <<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: