【输入】
n m k
(表示总共有n个人,编号为m的人在第k次拍手时实际上报到了数字几),结束标志为0 0 0
例如:
4 3 1
4 3 2
4 3 4
0 0 0
【输出】
17
21
35
#include<cstdio>
#include<cstring>
//判断函数,判断是否含有7,或者是7的倍数
bool judge(int n)
{
if(!(n % 7)) return true;
while (n)
{
if (n % 10 == 7)
return true;
n /= 10;
}
return false;
}
int main()
{
int n, m, k, i;
while (scanf("%d%d%d", &n, &m, &k)&&n&&m&&k)
{
int count = 0;
for (i = 7; ; i++)
{
if (judge(i))
{
int x = i % (2 * n - 2);//初始编号
if (x == 0)
x = 2 * n - 2;
//符合题意
if (x == m || (x >= n && 2 * n - x == m))
count++;
if (count == k)
break;
}
}
printf("%d\n", i);
}
return 0;
}