解题思路:
寻找规律
注意事项:
话不多说,代码简单易懂
参考代码:
#include<iostream>
using namespace std;
int main()
{
int n, m;
while (cin >> n >> m)
{
int a[1000], s = 0, k = 0, flag = 0;
for (int i = 1; i <= n; i++)
a[i] = 1;
for (int i = 1;; i++)
{
s += a[i];
if (s == m)
{
a[i] = 0;
k++;
s = 0;
}
if (k == (n - 1))
{
for (int i = 1; i <= n; i++)
{
if (a[i] == 1)
{
cout << i << endl;
flag = 1;
break;
}
}
}
if (i == n) i = 0;
if (flag == 1) break;
}
}
return 0;
}
0.0分
1 人评分