結果
問題 | No.2798 Multiple Chain |
ユーザー |
|
提出日時 | 2024-06-28 22:32:04 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 2,433 bytes |
コンパイル時間 | 2,179 ms |
コンパイル使用メモリ | 212,252 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-28 22:32:08 |
合計ジャッジ時間 | 3,491 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 3 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 1 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 1 ms
6,944 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 2 ms
6,944 KB |
testcase_34 | AC | 2 ms
6,944 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 1 ms
6,944 KB |
testcase_38 | AC | 1 ms
6,940 KB |
testcase_39 | AC | 2 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,944 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 1 ms
6,944 KB |
testcase_43 | AC | 2 ms
6,940 KB |
testcase_44 | AC | 2 ms
6,940 KB |
testcase_45 | AC | 2 ms
6,940 KB |
testcase_46 | AC | 2 ms
6,948 KB |
testcase_47 | AC | 1 ms
6,940 KB |
testcase_48 | AC | 2 ms
6,940 KB |
testcase_49 | AC | 2 ms
6,944 KB |
testcase_50 | AC | 2 ms
6,940 KB |
testcase_51 | AC | 2 ms
6,944 KB |
testcase_52 | AC | 2 ms
6,940 KB |
testcase_53 | AC | 2 ms
6,944 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; #define all(x) x.begin(),x.end() template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << " " << p.second; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #define ASSERT(...) 42 #endif typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int oo = 1e9; typedef unsigned long long ull; ull modmul(ull a, ull b, ull M) { ll ret = a*b - M*ull(1.L/M*a*b); return ret + M*(ret<0) - M*(ret>=(ll)M); } ull modpow(ull b, ull e, ull mod) { ull ans = 1; for(;e;b=modmul(b,b,mod),e/=2) { if(e&1) ans = modmul(ans,b,mod); } return ans; } ull pollard(ull n) { auto f = [n](ull x) {return modmul(x,x,n)+1;}; ull x =0,y=0, t=30,prd=2,i=1,q; while(t++ %40 || gcd(prd,n)==1) { if(x==y) x=++i, y = f(x); if((q=modmul(prd,max(x,y)-min(x,y),n))) prd=q; x = f(x),y=f(f(y)); } return gcd(prd,n); } bool isPrime(ull n) { if(n<2 || n%6%4!=1) return (n|1) ==3; ull A[] = {2,325,9375,28178, 450775,9780504, 17952650221}, s = __builtin_ctzll(n-1), d = n>>s; for(ull a : A) { ull p = modpow(a%n,d,n), i =s; while(p!=1 && p!=n-1 && a%n && i--) p = modmul(p,p,n); if(p!=n-1 && i!=s) return 0; } return 1; } map<ull,int> factor(ull n) { if(n==1 )return {}; if(isPrime(n)) return {{n,1}}; ull x = pollard(n); auto l = factor(x), r = factor(n/x); for(auto [i,c] : r) { l[i]+=c; } return l; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; auto mp = factor(n); ll ans=1; for(auto [k,v] : mp) { ll cur=0; auto rec = [&](auto&& self, int at, int sum, int len) { if(sum==v) { cur++; return; } while(at+sum<=v) { self(self,at,sum+at,len+1); at++; } }; rec(rec,1,0,0); ans*=cur; } cout << ans << '\n'; }