結果
問題 | No.2798 Multiple Chain |
ユーザー | kwm_t |
提出日時 | 2024-06-28 23:13:53 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,328 bytes |
コンパイル時間 | 3,194 ms |
コンパイル使用メモリ | 254,460 KB |
実行使用メモリ | 7,520 KB |
最終ジャッジ日時 | 2024-06-28 23:14:00 |
合計ジャッジ時間 | 6,724 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
7,516 KB |
testcase_01 | AC | 38 ms
7,520 KB |
testcase_02 | AC | 39 ms
7,512 KB |
testcase_03 | AC | 39 ms
7,516 KB |
testcase_04 | AC | 39 ms
7,516 KB |
testcase_05 | AC | 39 ms
7,388 KB |
testcase_06 | AC | 39 ms
7,512 KB |
testcase_07 | AC | 40 ms
7,388 KB |
testcase_08 | AC | 39 ms
7,392 KB |
testcase_09 | AC | 39 ms
7,388 KB |
testcase_10 | AC | 38 ms
7,516 KB |
testcase_11 | AC | 39 ms
7,388 KB |
testcase_12 | AC | 38 ms
7,516 KB |
testcase_13 | AC | 39 ms
7,388 KB |
testcase_14 | AC | 39 ms
7,372 KB |
testcase_15 | AC | 40 ms
7,392 KB |
testcase_16 | AC | 40 ms
7,516 KB |
testcase_17 | AC | 40 ms
7,516 KB |
testcase_18 | AC | 39 ms
7,512 KB |
testcase_19 | AC | 39 ms
7,384 KB |
testcase_20 | AC | 39 ms
7,516 KB |
testcase_21 | AC | 38 ms
7,388 KB |
testcase_22 | AC | 39 ms
7,516 KB |
testcase_23 | AC | 39 ms
7,436 KB |
testcase_24 | AC | 39 ms
7,516 KB |
testcase_25 | AC | 39 ms
7,516 KB |
testcase_26 | AC | 39 ms
7,392 KB |
testcase_27 | AC | 39 ms
7,516 KB |
testcase_28 | AC | 39 ms
7,392 KB |
testcase_29 | AC | 39 ms
7,516 KB |
testcase_30 | AC | 39 ms
7,388 KB |
testcase_31 | AC | 39 ms
7,516 KB |
testcase_32 | WA | - |
testcase_33 | AC | 39 ms
7,392 KB |
testcase_34 | WA | - |
testcase_35 | AC | 39 ms
7,388 KB |
testcase_36 | AC | 39 ms
7,516 KB |
testcase_37 | AC | 39 ms
7,388 KB |
testcase_38 | AC | 40 ms
7,516 KB |
testcase_39 | AC | 41 ms
7,512 KB |
testcase_40 | AC | 39 ms
7,388 KB |
testcase_41 | AC | 39 ms
7,516 KB |
testcase_42 | AC | 39 ms
7,392 KB |
testcase_43 | AC | 39 ms
7,516 KB |
testcase_44 | AC | 39 ms
7,384 KB |
testcase_45 | AC | 39 ms
7,384 KB |
testcase_46 | AC | 39 ms
7,516 KB |
testcase_47 | AC | 39 ms
7,512 KB |
testcase_48 | AC | 39 ms
7,392 KB |
testcase_49 | AC | 39 ms
7,516 KB |
testcase_50 | AC | 39 ms
7,516 KB |
testcase_51 | AC | 39 ms
7,392 KB |
testcase_52 | AC | 39 ms
7,392 KB |
testcase_53 | AC | 39 ms
7,512 KB |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair<int,int> template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } // 存在しなければ -1 を return long long _sqrt(long long x) { if (x < 0)return -1; long long ng = -1; long long ok = 3 * (long long)INF + 1; while (1 < abs(ok - ng)) { long long c = (ng + ok) / 2; auto check = [&]() { return x <= c * c; }; if (check()) ok = c; else ng = c; } long long ret = ok; if (ret * ret != x)ret = -1; return ret; } std::vector<long long> sieveOfEratosthenes(long long n = 1000000) { std::vector<bool>p(n + 1, true); std::vector<long long>ret; p[0] = false; p[1] = false; for (int i = 2; i <= n; ++i) { if (!p[i]) continue; ret.push_back(i); for (int j = 2 * i; j <= n; j += i) p[j] = false; } return ret; } void solve(long long n) { auto pv = sieveOfEratosthenes(); set<long long>st; for (auto p : pv)st.insert(p); long long ans = 1; vector<long long>devide = { 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490, 627, 792, 1002, 1255, 1575, 1958, 2436, 3010, 3718, 4565, 5604, 6842, 8349, 10143, 12310 }; for (long long i = 1; i < 1000001; ++i) { if (0 != n % i)continue; // n = p^2 * q // i = min(p,q) long long p = -1; if (st.count(i) && 0 == n % (i * i)) { p = i; } else { auto p = _sqrt(n / i); } if (-1 == p)continue; int cnt = 0; while (0 == n % i) { cnt++; n /= i; } //cout << p << " " << cnt << endl; ans *= devide[cnt]; } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long n; cin >> n; solve(n); return 0; }