UVa 10050 - Hartals解题报告

来源:互联网 发布:linux无法重启网络服务 编辑:程序博客网 时间:2024/05/16 15:35

题意:一共n天,给出a1,a2...在它们的倍数日罢工,但是周六周日不罢工,输出n天中罢工的天数

思路:用数组模拟。

//10050 - Hartals#include <iostream>#include <cstring>using namespace std;bool unwork[3700];int main(){//freopen("data.txt", "r", stdin);int cases;scanf("%d", &cases);while (cases--){int n, p, x, unwork_day = 0;scanf("%d", &n);scanf("%d", &p);for(int i = 0; i < p; i++){scanf("%d", &x);int s = x;while(s <= n){if(!unwork[s] && s % 7 != 6 && s % 7 != 0){unwork[s] = true;unwork_day++;}s += x;}}printf("%d\n", unwork_day);memset(unwork, 0, sizeof(unwork));}return 0;}


0 0
原创粉丝点击