UVA - 10050 Hartals
来源:互联网 发布:怎么下载淘宝卖家版 编辑:程序博客网 时间:2024/06/02 17:02
Consider three political parties. Assume h1 = 3, h2 = 4 andh3 = 8 wherehi is the hartal parameter for partyi (i = 1, 2, 3). Now, we will simulate the behavior of these three parties forN = 14 days. One must always start the simulation on a Sunday and assume that there will be nohartals on weekly holidays (on Fridays and Saturdays).
The simulation above shows that there will be exactly 5 hartals (on days 3, 4, 8, 9 and 12) in 14 days. There will be nohartal on day 6 since it is a Friday. Hence we lose 5 working days in 2 weeks.
In this problem, given the hartal parameters for several political parties and the value ofN, your job is to determine the number of working days we lose in thoseN days.
Input
The first line of the input consists of a single integer T giving the number of test cases to follow.
The first line of each test case contains an integer N ( ) giving the number of days over which the simulation must be run. The next line contains another integer P ( ) representing the number of political parties in this case. The i�th of the next P lines contains a positive integerhi (which will never be a multiple of 7) giving thehartal parameter for party i ( ).
Output
For each test case in the input output the number of working days we lose. Each output must be on a separate line.
Sample Input
2143348100412152540
Sample Output
515
题意:
给出天数,以及党的个数,还有罢工的周期,求出最后罢工的天数,星期五以及星期六不算在内;
<pre name="code" class="cpp">#include<cstdio>#include<cstring>#include<iostream>using namespace std;int main(){int n;int d;int p;int a[4000];int b[4000];cin >> n;while(n --){cin >> d;cin >> p;memset(b,0,sizeof(b));for(int i = 1; i <= p; i ++){cin >> a[i];for(int j = a[i]; j <= d; j += a[i])b[j] = 1;}int day= 0;for(int k = 1; k <= d; k++){if(b[k] && (k +7) % 7 - 1 != 5 && (k +7) %7 + 7- 1 != 6)day ++ ;}printf("%d\n",day);}return 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
- linux 执行 iptables 命令出错 segmentation fault (core dumped) 的解决
- win32_First day
- 比较热门的两款noSQL(Redis & mongoDB)产品读写性能对比
- 暴力子字符串查找
- solr4.9原子更新solrj例子
- UVA - 10050 Hartals
- 【html5基础】HTML5 知识点
- 基于VISA的编程中,ViString与CString之间转换的关系
- Bone Collector+hdu+一道01背包的最基本模板
- poj 1948
- LeetCode-Sudoku Solver
- struts2验证框架后台验证用户注册
- 百度地图及定位使用
- 解决cocos2d-X 2.0版本后创建的Android项目提示org.cocos2dx.lib.Cocos2dxActivity找不到问题