codeforces水题100道 第四题 Codeforces Round #105 (Div. 2) A. Insomnia cure (math)

题目链接:http://www.codeforces.com/problemset/problem/148/A
题意:求1到d中有多少个数能被k,l,m,n中的至少一个数整出。
C++代码:

#include <iostream>
using namespace std;
int k, l, m, n, d, ans;
int main()
{
    cin >> k >>l >> m >> n >> d;
    for (int i = 1; i <= d; i ++)
        if (i % k == 0 || i % l == 0 || i % m == 0 || i % n == 0)
            ans ++;
    cout << ans;
    return 0;
}
C++

 

posted @ 2016-07-20 15:56  月光诗人  阅读(310)  评论(0编辑  收藏  举报