結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー haruteruharuteru
提出日時 2016-01-25 10:16:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 834 bytes
コンパイル時間 1,485 ms
コンパイル使用メモリ 67,520 KB
実行使用メモリ 217,704 KB
最終ジャッジ日時 2023-10-21 14:57:39
合計ジャッジ時間 4,246 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
26,768 KB
testcase_01 AC 781 ms
88,472 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>

const long long max = 10e9;
std::map<long long, int> f;

long long calc(long long n, long long N)
{
    long long cnt = 0;
    for (long long i = n; i <= N; i += n) {
        if (f[i] == 0) {
            cnt += 1;
            f[i] = 1;
        }
    }
    return cnt;
}

int main()
{
    long long N;
    long long n[3];
    long long cnt = 0;

    std::cin >> N;
    std::cin >> n[0];
    std::cin >> n[1];
    std::cin >> n[2];

    for (int i = 0; i < 3; i++) {
        if (n[i] == 0) {
            std::cout << -1 << std::endl;
            return 0;
        }
        if (n[i] == 1) {
            std::cout << N << std::endl;
            return 0;
        }
    }

    cnt += calc(n[0], N);
    cnt += calc(n[1], N);
    cnt += calc(n[2], N);
    std::cout << cnt << std::endl;
    return 0;
}
0