結果

問題 No.1498 Factorization from -1 to 1
ユーザー t33ft33f
提出日時 2021-05-08 14:40:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 917 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 76,744 KB
実行使用メモリ 11,700 KB
最終ジャッジ日時 2023-10-15 01:41:45
合計ジャッジ時間 5,499 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
10,980 KB
testcase_01 AC 35 ms
11,132 KB
testcase_02 AC 34 ms
11,036 KB
testcase_03 AC 195 ms
11,100 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 35 ms
10,980 KB
testcase_16 AC 35 ms
11,412 KB
testcase_17 AC 35 ms
11,700 KB
testcase_18 AC 35 ms
10,948 KB
testcase_19 AC 36 ms
10,944 KB
testcase_20 AC 35 ms
11,124 KB
testcase_21 AC 36 ms
10,980 KB
testcase_22 AC 36 ms
11,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
using namespace std;
int main() {
    vector<vector<long long> > factors(100100);
    vector<long long> rem(100100);
    for (int i = 1; i < rem.size(); i++)
        rem[i] = (long long)i * i + 1;
    for (int i = 1; i < factors.size(); i++) {
        long long p = rem[i];
        if (p == 1) continue;
        for (long long j = i; j < 100100; j += p)
            while (rem[j] % p == 0) {
                rem[j] /= p;
                factors[j].push_back(p);
            }
        for (long long j = p - i; j < 100100; j += p)
            while (rem[j] % p == 0) {
                rem[j] /= p;
                factors[j].push_back(p);
            }
    }
    
    int q; cin >> q;
    while (q--) {
        int k; cin >> k;
        for (int i = 0; i < factors[k].size(); i++) {
            cout << factors[k][i] << (i == factors[k].size() - 1 ? '\n' : ' ');
        }
    }
}
0