UVA 10050 Hartals
来源:互联网 发布:怎么在爱淘宝上开店 编辑:程序博客网 时间:2024/05/19 21:42
Problem D: Hartals
A social research organization has determined a simple set of parameters to simulate the behavior of the political parties of our country. One of the parameters is a positive integer h (called the hartal parameter) that denotes the average number of days between two successive hartals (strikes) called by the corresponding party. Though the parameter is far too simple to be flawless, it can still be used to forecast the damages caused by hartals. The following example will give you a clear idea:
Consider three political parties. Assume h1 = 3, h2 = 4 and h3 = 8 where hi is the hartal parameter for party i ( i = 1, 2, 3). Now, we will simulate the behavior of these three parties for N = 14 days. One must always start the simulation on a Sunday and assume that there will be no hartals 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 no hartal 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 of N, your job is to determine the number of working days we lose in those N 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 ith of the next P lines contains a positive integer hi (which will never be a multiple of 7) giving the hartal 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
题意: 给定总天数,再给定一些开party的周期,如果在周五周六开party不算罢工,其他时间算罢工。要求出总罢工天数。
#include <stdio.h>#include <string.h>int t;int n;int p;int sb[105];int vis[3666];int main(){ scanf("%d", &t); while (t --) {memset(vis, 0, sizeof(vis));vis[0] = 1;int sum = 0;memset(sb, 0, sizeof(sb));scanf("%d%d", &n, &p);for (int i = 0; i < p; i ++){ scanf("%d", &sb[i]); int t = sb[i]; int d = 0; while (d <= n) {if(vis[d] == 0 && (d - 6) % 7 && (d - 7) % 7){ sum ++; vis[d] = 1;}d += t; }}printf("%d\n", sum); } 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
- VS2010安装/瘦身/精简/提速方法
- hdu 3729 I'm Telling the Truth(最大匹配)
- JAVA学习二十:IO流
- 剑指Offer算法实现之八:旋转数组的最小数字
- JAVA学习二十一:GUI图形用户界面
- UVA 10050 Hartals
- [leetcode] Longest Valid Parentheses
- 程序员,你当的了吗?——读《高效能程序员的修炼》有感
- HTTP 错误 500.21 - Internal Server Error 处理程序“PageHandlerFactory-ISAPI-4.0_32bit”在其模块
- 《iOS应用程序开发方法与实践》补充内容-2.13 再谈类的声明与实现
- UVA 123 Searching Quickly
- 权限系统设计思考
- const在c/c++中的区别
- C# CultureInfo列表详细说明