UVA - 10050 Hartals
2016-07-26 19:59
489 查看
题目大意:给 T 个样例,连续 N 天,从周日开始,P 个队伍,每个队伍罢工的日子是所给队伍数字的倍数,多个队伍在同一天罢工只算一次,且周五周六不算,问罢工天数。
解题思路:模拟,把罢工天数置为 1,每周五周六置为 0,最后扫一遍。
解题思路:模拟,把罢工天数置为 1,每周五周六置为 0,最后扫一遍。
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<ctype.h> using namespace std; int team[120]; int day[10000]; int main() { int T; scanf("%d", &T); while (T--) { memset(day, 0, sizeof(day)); int N, P; scanf("%d%d", &N, &P); for (int i = 0; i < P; i++) scanf("%d", &team[i]); for (int i = 0; i < P; i++) { int tag = 1; while (team[i]*tag <= N) { day[team[i]*tag] = 1; tag++; } } for (int i = 6; i <= N; i += 7) { day[i] = 0; day[i+1] = 0; } int cnt = 0; for (int i = 1; i <= N; i++) if (day[i] == 1) cnt++; printf("%d\n", cnt); } return 0; }
相关文章推荐
- 1.10055 - Hashmat the brave warrior
- 2.10071 - Back to High School Physics
- 3.458 - The Decoder
- 4.694 - The Collatz Sequence
- 6.494 - Kindergarten Counting Game
- 7.490 - Rotating Sentences
- 8.414 - Machined Surfaces
- 9.488 - Triangle Wave
- A.457 - Linear Cellular Automata
- B.489 - Hangman Judge
- C.445 - Marvelous Mazes
- 1.10494 - If We Were a Child Again
- 2.424 - Integer Inquiry
- 3.10250 - The Other Two Trees
- 5.465 - Overflow
- 6.113 - Power of Cryptography
- 7.10161 - Ant on a Chessboard
- 8.621 - Secret Research
- 9.401 - Palindromes
- A.537 - Artificial Intelligence?