[一天至少一题直到ICPC开赛005]解题: Hartals(12/14)

Hartals

题目连结

解题

因为其输入是间隔天数,在五六不算所以用set判断,可以避免重複。

code

#include <iostream>#include <vector>#include <map>#include <set>using namespace std;int main(int argc, char const *argv[]){    int t;    cin >> t;    while (t--)    {        int d, n;        cin >> d >> n;        set<int> streetday;        for (int i = 0; i < n; i++)        {            int x;            cin >> x;            int c = x;            while (x <= d)            {                if (x % 7 != 6 && x % 7 != 0 && streetday.count(x) == 0)                {                    streetday.insert(x);                }                x = x + c;            }        }        cout << streetday.size() << endl;    }    return 0;}

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章