#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
int n,k;
bool visit[N];
bool check(int t)
{
if(t%k==0 || t%10==k)
return true;
return false;
}
int main()
{
cin >> n >> k;
int num=1,cnt=n,flag=0;
while(1)
{
for(int i=1;i<=n;i++)
{
if(!visit[i])
{
if(check(num)) //num是k的倍数或者末尾是k
{
visit[i]=true; //被淘汰
cnt--;
if(cnt==1)
{
flag=1;
break;
}
num++;
}
else
num++;
}
}
if(flag) break;
}
for(int i=1;i<=n;i++)
if(!visit[i])
cout << i << endl;
return 0;
}
/*
In every life we have some trouble. When you worry you make it double.
Don't worry,be happy.
.-~~~~~~~~~-._ _.-~~~~~~~~~-.
__.' ~. .~ `.__
.'// \./ \`.
.'// | \`.
.'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \`.
.'//.-" `-. | .-' "-.\`.
.'//______.============-.. \ | / ..-============.______\`.
.'______________________________\|/______________________________`.
*/
csp-游戏
于 2021-10-24 10:29:42 首次发布