結果

問題 No.550 夏休みの思い出(1)
ユーザー pekempeypekempey
提出日時 2017-07-28 23:01:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,515 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 80,124 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 13:09:01
合計ジャッジ時間 1,882 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,940 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 AC 3 ms
6,944 KB
testcase_30 AC 3 ms
6,944 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 3 ms
6,948 KB
testcase_33 AC 3 ms
6,944 KB
testcase_34 AC 3 ms
6,944 KB
testcase_35 AC 3 ms
6,940 KB
testcase_36 AC 3 ms
6,944 KB
testcase_37 AC 3 ms
6,940 KB
testcase_38 AC 3 ms
6,944 KB
testcase_39 AC 3 ms
6,944 KB
testcase_40 AC 3 ms
6,944 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 3 ms
6,940 KB
testcase_43 AC 3 ms
6,944 KB
testcase_44 AC 3 ms
6,940 KB
testcase_45 AC 3 ms
6,944 KB
testcase_46 AC 3 ms
6,940 KB
testcase_47 AC 3 ms
6,940 KB
testcase_48 AC 3 ms
6,944 KB
testcase_49 AC 3 ms
6,940 KB
testcase_50 AC 2 ms
6,940 KB
testcase_51 AC 3 ms
6,940 KB
testcase_52 AC 3 ms
6,940 KB
testcase_53 AC 3 ms
6,944 KB
testcase_54 AC 4 ms
6,940 KB
testcase_55 AC 3 ms
6,944 KB
testcase_56 AC 3 ms
6,940 KB
testcase_57 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

constexpr int MOD = 100003;

struct modint {
    int n;
    modint(int n = 0) : n(n) {}
};

modint operator+(modint a, modint b) { return modint((a.n += b.n) >= MOD ? a.n - MOD : a.n); }
modint operator-(modint a, modint b) { return modint((a.n -= b.n) < 0 ? a.n + MOD : a.n); }
modint operator*(modint a, modint b) { return modint(1LL * a.n * b.n % MOD); }
modint &operator+=(modint &a, modint b) { return a = a + b; }
modint &operator-=(modint &a, modint b) { return a = a - b; }
modint &operator*=(modint &a, modint b) { return a = a * b; }

int main() {
    long long a, b, c;
    std::cin >> a >> b >> c;

    modint A(((a % MOD) + MOD) % MOD);
    modint B(((b % MOD) + MOD) % MOD);
    modint C(((c % MOD) + MOD) % MOD);

    std::vector<bool> check(MOD + 1);
    for (int i = 0; i < MOD; i++) {
        modint x = i;
        if ((x * x * x + A * x * x + B * x + C).n == 0) check[i] = true;
    }

    std::set<long long> ans;
    for (long long i = 0; i < MOD; i++) {
        if (!check[i]) continue;
        for (long long j = i; j <= 1000000000; j += MOD) {
            __int128 x = j;
            if (x * x * x + a * x * x + b * x + c == 0) ans.insert(x);
        }
        for (long long j = i; j >= -1000000000; j -= MOD) {
            __int128 x = j;
            if (x * x * x + a * x * x + b * x + c == 0) ans.insert(x);
        }
    }

    for (long long x : ans) {
        std::cout << x << ' ';
    }
}
0