试题编号 | 201912-1 |
试题名称 | 报数 |
时间限制 | 1.0s |
内存限制 | 512.0MB |
#include<cstdio>
int n;
int skip[4];
bool judge(int n){//判断是否包含7
int t = 0;
while (n && t!=7){
t = n % 10;
n /= 10;
}
if (t == 7)
return true;
else
return false;
}
int main()
{
scanf("%d", &n);
int turn = 0;//轮到谁:0,1,2,3
int cnt = 0;//数了多少数,不包含跳过的数
int i = 1;
while (cnt < n){//当cnt==n时,不满足cnt<n,此时跳出循环
if (i % 7 == 0 || judge(i)){//7的倍数或含有数字7
skip[turn]++;
}
else cnt++;
turn = (turn + 1) % 4;
i++;
}
for (int i = 0; i < 4; i++)
printf("%d\n", skip[i]);
return 0;
}