結果
問題 | No.2365 Present of good number |
ユーザー | rnano |
提出日時 | 2023-07-01 00:05:43 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,265 bytes |
コンパイル時間 | 1,783 ms |
コンパイル使用メモリ | 187,660 KB |
実行使用メモリ | 11,056 KB |
最終ジャッジ日時 | 2024-07-07 11:45:27 |
合計ジャッジ時間 | 3,650 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
7,296 KB |
testcase_01 | AC | 20 ms
7,088 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 20 ms
7,364 KB |
testcase_05 | AC | 20 ms
7,240 KB |
testcase_06 | AC | 20 ms
7,232 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 20 ms
7,360 KB |
testcase_10 | WA | - |
testcase_11 | AC | 20 ms
7,224 KB |
testcase_12 | AC | 20 ms
7,236 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 20 ms
7,228 KB |
testcase_16 | AC | 19 ms
7,224 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 19 ms
7,284 KB |
testcase_20 | AC | 21 ms
7,220 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 19 ms
7,236 KB |
testcase_24 | AC | 20 ms
7,352 KB |
testcase_25 | AC | 19 ms
7,168 KB |
testcase_26 | AC | 19 ms
7,236 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 21 ms
7,348 KB |
testcase_33 | AC | 20 ms
7,220 KB |
testcase_34 | AC | 20 ms
7,296 KB |
testcase_35 | AC | 19 ms
7,224 KB |
testcase_36 | WA | - |
testcase_37 | AC | 23 ms
7,368 KB |
testcase_38 | AC | 20 ms
7,240 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (int)(n); ++i) #define rrep(i,n) for (int i = (int)(n-1); i >= 0; --i) #define Rep(i,a,b) for (int i = a; i < b; ++i) #define rRep(i,a,b) for (int i = a; i > b; --i) #define fore(i,a) for(auto &i:a) #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define Unique(v) v.erase(unique(v.begin(), v.end()), v.end()); #define Bit(x,i) (((x)>>(i))&1) using ll = long long; using vi = vector<int>; using vll = vector<long long>; using vvi = vector<vi>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; using pii = pair<int, int>; using pll = pair<ll, ll>; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } struct settings{settings(){ios_base::sync_with_stdio(0); cin.tie(0); cout<<fixed<<setprecision(15);};}settingss; const double PI = acos(-1); const int INF = 1001001001; const ll LINF = 1001001001001001001LL; const int mod = 1000000007; class modint { long long x; public: modint(long long x=0) : x((x%mod+mod)%mod) {} modint operator-() const { return modint(-x); } modint& operator+=(const modint& a) { if ((x += a.x) >= mod) x -= mod; return *this; } modint& operator-=(const modint& a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } modint& operator*=(const modint& a) { (x *= a.x) %= mod; return *this; } modint operator+(const modint& a) const { modint res(*this); return res+=a; } modint operator-(const modint& a) const { modint res(*this); return res-=a; } modint operator*(const modint& a) const { modint res(*this); return res*=a; } modint pow(ll t) const { if (!t) return 1; modint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } modint inv() const { return pow(mod-2); } modint& operator/=(const modint& a) { return (*this) *= a.inv(); } modint operator/(const modint& a) const { modint res(*this); return res/=a; } friend ostream& operator<<(ostream& os, const modint& m){ os << m.x; return os; } }; ll powmod(ll n, ll p, ll m) { if(p == 0) return 1; ll res = powmod(n, p/2, m); n %= m; if(p%2 == 0) return (res*res) % m; return (((res*res) % m)*n) % m; } vector<int> Eratosthenes(int N) { vector<bool> is_prime(N+1); for(int i=0; i<=N; ++i) { is_prime[i] = true; } vector<int> ret; for(int i=2; i<=N; ++i) { if(is_prime[i]) { for(int j=2*i; j<=N; j+=i) { is_prime[j] = false; } ret.emplace_back(i); } } return ret; } ll dp[100][10010]; map<ll, ll> mp; vector<vector<pll>> nx(10010); int main() { ll N, K; cin >> N >> K; vi prm = Eratosthenes(100000); int ps = prm.size(); ll iid = 0; fore(p, prm) { mp[p] = iid; ++iid; } int NN = N; for(int i = 2; i*i <= NN; ++i) { int cnt = 0; while(N % i == 0) { cnt++; N /= i; } dp[0][mp[i]] = cnt; } if(N > 1) dp[0][mp[N]] = 1; rep(i, ps) { int pp = prm[i]+1; int ppp = pp; for(int j = 2; j * j <= ppp; ++j) { int cnt = 0; while(pp % j == 0) { pp /= j; cnt++; } if(cnt > 0) { nx[i].push_back({mp[j], cnt}); } } if(pp > 1) { nx[i].push_back({mp[pp], 1LL}); } } rep(k, 52) { rep(i, ps) { fore(nnx, nx[i]) { dp[k+1][nnx.first] += nnx.second * dp[k][i]; } } } modint ans = 1; if(K < 50) { rep(i, ps) { ans *= powmod(prm[i], dp[K][i], mod); } cout << ans << endl; return 0; } K -= 50; ll two = dp[50][0]; ll thr = dp[50][1]; ll mm = K%2; K /= 2; // 2^(two * 2^K) ll ppow = powmod(2, K, mod-1); // cout << two << ' ' << thr << ' ' << ppow << endl; if(mm) { ans *= powmod(3, two * ppow, mod); ans *= powmod(2, thr * ppow * 2, mod); } else { ans *= powmod(2, two * ppow, mod); ans *= powmod(3, thr * ppow, mod); } cout << ans << endl; /* ll KK = 1000000000000LL; ll pppow = powmod(2, KK/2, mod-1); // 2^2^KK cout << pppow << endl; cout << powmod(2, pppow, mod); */ }