結果
問題 | No.2798 Multiple Chain |
ユーザー | bortik |
提出日時 | 2024-06-28 23:05:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,813 bytes |
コンパイル時間 | 3,271 ms |
コンパイル使用メモリ | 236,264 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-28 23:05:24 |
合計ジャッジ時間 | 17,813 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | TLE | - |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 1,579 ms
5,376 KB |
testcase_21 | AC | 1,190 ms
5,376 KB |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | AC | 1,922 ms
6,940 KB |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 1 ms
5,376 KB |
testcase_28 | AC | 1 ms
5,376 KB |
testcase_29 | AC | 1 ms
5,376 KB |
testcase_30 | WA | - |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 92 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 859 ms
5,376 KB |
testcase_35 | AC | 1 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | WA | - |
testcase_38 | AC | 4 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 1 ms
5,376 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | AC | 1 ms
5,376 KB |
testcase_48 | AC | 1 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 21 ms
5,376 KB |
testcase_52 | AC | 29 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
ソースコード
// https://codeforces.com/blog/entry/96344 #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; using ll = long long; using u32 = unsigned int; using u64 = unsigned long long; using i128 = __int128; using u128 = unsigned __int128; using f128 = __float128; template<typename T> bool chmax(T& a, const T& b) { bool res = a < b; a = max(a, b); return res; } template<typename T> bool chmin(T& a, const T& b){ bool res = a > b; a = min(a, b); return res; } typedef vector<long long> vl; typedef pair<ll,ll> pll; typedef vector<pair<ll, ll>> vll; typedef vector<int> vi; typedef vector<pair<int,int>> vii; typedef pair<int,int> pii; const int inf = 1000000009; const ll linf = 4000000000000000009; // https://trap.jp/post/1224/ template<class... T> void input(T&... a){ (cin >> ... >> a); } void print(){ cout << '\n'; } template<class T, class... Ts> void print(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } #define rep1(a) for(int i = 0; i < a; i++) #define rep2(i, a) for(int i = 0; i < a; i++) #define rep3(i, a, b) for(int i = a; i < b; i++) #define rep4(i, a, b, c) for(int i = a; i < b; i += c) #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define eb emplace_back #define mp make_pair #define mt make_tuple #define fi first #define se second //--------------------------------- vector<ll> part(ll n, ll m){ vector dp(m+1, vector<ll>(n+1, 0)); dp[0][0] = 1; rep(i, 1, m+1){ rep(j, n+1){ if(j-i >= 0){ dp[i][j] = dp[i-1][j] + dp[i][j-i]; } else { dp[i][j] = dp[i-1][j]; } } } vector<ll> res(m); rep(i, m){ res[i] = dp[i][n]; } return res; } template <typename T> std::vector<std::pair<T, T>> prime_factor(T n) { std::vector<std::pair<T, T>> ret; for (T i = 2; i * i <= n; i++) { if (n % i != 0) continue; T tmp = 0; while (n % i == 0) { tmp++; n /= i; } ret.push_back(std::make_pair(i, tmp)); } if (n != 1) ret.push_back(std::make_pair(n, 1)); return ret; } vector<long long> trial_division3(long long n) { vector<long long> factorization; for (int d : {2, 3, 5}) { while (n % d == 0) { factorization.push_back(d); n /= d; } } static array<int, 8> increments = {4, 2, 4, 2, 4, 6, 2, 6}; int i = 0; for (long long d = 7; d * d <= n; d += increments[i++]) { while (n % d == 0) { factorization.push_back(d); n /= d; } if (i == 8) i = 0; } if (n > 1) factorization.push_back(n); return factorization; } void solve(){ ll n; cin >> n; auto facts = trial_division3(n); map<ll,ll> fs; for(auto j: facts) fs[j] += 1; vector<vector<ll>> parts; ll mx = 0; //cout << "HELLO" << endl; for(auto [p, e]: fs){ if(e==1) continue; parts.push_back(part(e, 10)); //print(p, e); chmax(mx, e); } ll ans = 1; int s = parts.size(); rep(L, 2, mx+1){ rep(j, s){ ll cur = parts[j][L]-parts[j][L-1]; if(cur < 1) continue; rep(i, j){ cur *= parts[i][L-1]; } rep(i, j+1, s){ cur *= parts[i][L]; } ans += cur; } //print(parts[0][L]-parts[0][L-1]); } print(ans); } int main(){ ios::sync_with_stdio(false); cin.tie(0); int t = 1; //cin >> t; rep(i,0,t) solve(); }