UVA - 10050 Hartals
来源:互联网 发布:祸害成患妖成灾网络剧1 编辑:程序博客网 时间:2024/05/22 01:53
题目大意:给 T 个样例,连续 N 天,从周日开始,P 个队伍,每个队伍罢工的日子是所给队伍数字的倍数,多个队伍在同一天罢工只算一次,且周五周六不算,问罢工天数。
解题思路:模拟,把罢工天数置为 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;}
0 0
- uva 10050 - Hartals
- UVa 10050 - Hartals
- uva 10050 - Hartals//水题
- UVa 10050 - Hartals
- UVA 10050 - Hartals
- uva 10050Hartals
- uva-10050 Hartals
- UVa 10050 - Hartals
- UVA 10050 Hartals
- uva 10050 - Hartals
- uva 10050 Hartals
- uva 10050Hartals
- UVa 10050 Hartals
- UVa 10050 - Hartals
- UVA - 10050 - Hartals
- UVA - 10050 Hartals
- UVa-10050-Hartals
- UVA - 10050 Hartals
- Codeforces 435D Special Grid
- 【CodeForces】[670D2]Magic Powder - 2
- 自定义控件三部曲之绘图篇(十八)——BitmapShader与望远镜效果
- NGINX负载均衡
- 解决 object references an unsaved transient instance - save the transient instance before flushing
- UVA - 10050 Hartals
- STM32自学笔记——外部中断
- SpringAOP注解方式记录操作日志(操作模块,操作功能,调用方法,主键信息等)支持多笔操作时记录
- I/O流之File类常用方法(2)
- Object 详解
- java工具类开发之json工具类JsonUtils和写数据回页面工具类ResponseUtils
- UVA - 540 Team Queue
- .net 执行多条cmd 命令方法与大批量CSV文件合并成一个文件方法
- 使用Gallery控件实现个人相簿功能