uva10050
来源:互联网 发布:淘宝买家申请售后换货 编辑:程序博客网 时间:2024/05/22 14:17
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=991
10050 - Hartals
Time limit: 3.000 seconds
Problem D:HartalsA social research organization has determined a simple set ofparameters to simulate the behavior of the political parties of ourcountry. One of the parameters is a positive integerh(called the hartal parameter) that denotes the averagenumber of days between two successive hartals (strikes)called by the corresponding party. Though the parameter is far toosimple to be flawless, it can still be used to forecast the damagescaused by hartals. The following example will give you aclear idea:
Consider three political parties. Assume h1 =3,h2 = 4 and h3 = 8 wherehi is the hartal parameter forparty i(i = 1, 2, 3).Now, we will simulate the behavior of these three parties forN = 14 days. One must always start the simulation on aSunday and assume that there will be no hartals on weeklyholidays (on Fridays and Saturdays).
The simulation above shows that there will be exactly 5hartals (on days 3, 4, 8, 9 and 12) in 14 days. There willbe no hartal on day 6 since it is a Friday. Hence we lose5 working days in 2 weeks.
In this problem, given the hartal parameters for severalpolitical parties and the value of N, your job is todetermine the number of working days we lose in those Ndays.
Input
The first line of the input consists of a single integerT giving the number of test cases to follow.
The first line of each test case contains an integerN () giving the number of days over which the simulationmust be run. The next line contains another integer P () representing the number of political parties inthis case. The ith of the next Plines contains a positive integer hi(which will never be a multiple of 7) giving the hartalparameter for party i ().
Output
For each test case in the input output the number of workingdays we lose. Each output must be on a separate line.
Sample Input
2143348100412152540
Sample Output
515
题意:在按星期算的时间里每到某一天都要罢工,求在指定的天数内罢工的天数
#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int a[4000];
int
int main()
{