UVa 10050 - Hartals

来源:互联网 发布:医疗与大数据 编辑:程序博客网 时间:2024/05/29 09:12

题意给出了一共的天数。和party。用数组模拟就可以。记录days[i]的倍数。最后做mod 排除 周五 周六


// File Name: UVa10050.cpp// Author: Toy// Created Time: 2013年03月26日 星期二 20时52分02秒#include <iostream>#include <cstdio>#include <cstring>#include <vector>#include <cctype>#include <cmath>#include <string>#include <algorithm>#include <cstdlib>#include <iomanip>#include <list>#include <map>#include <set>#include <deque>#include <stack>#include <bitset>#define L(x) x << 1#define R(x) x << 1 | 1using namespace std;int days[3700], Case, day, party, tmp, x, cmp;int main ( ) {    scanf ( "%d", &Case );    while ( Case-- ) {memset ( days, 0, sizeof ( days ) );scanf ( "%d%d", &day, &party );for ( int i = 0; i < party; ++i ) {    tmp = 1;    scanf ( "%d", &x );            cmp = x;    while ( cmp <= day ) {days[cmp]++;tmp++;cmp = x * tmp;    }}int ans = 0;for ( int i = 0; i <= day; ++i )     if ( days[i] &&  ( i - 1 ) % 7 != 5 && ( i - 1 ) % 7 != 6 ) ans++; printf ( "%d\n", ans );    }    return 0;}