文章
6
粉丝
137
获赞
2
访问
5.8k
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define N 10010
int a[N], b[N], c[N]; //用来存放每个礼炮车的发射时间
int num[N]; //存放没有重复的声响时间
int count = 0; //记录观众可以听到的声响
bool isRepeat(int a)
{
for(int i = 0; i < count; i++)
if(a == num[i]) return true;
return false;
}
int main()
{
int i;
a[1] = b[1] = c[1] = 1;
for(i = 2; i <= 21; i++)
{
a[i] = a[i - 1] + 5;
b[i] = b[i - 1] + 6;
c[i] = c[i - 1] + 7;
}
for(i = 1; i <= 21; i++)
{
if(!isRepeat(a[i])) num[count++] = a[i];
if(!isRepeat(b[i])) num[count++] = b[i];
if(!isRepeat(c[i])) num[count++] = c[i];
}
printf("%d\n", count);
return 0;
}
登录后发布评论
暂无评论,来抢沙发