結果
問題 | No.890 移調の限られた旋法 |
ユーザー | NyaanNyaan |
提出日時 | 2019-09-20 21:51:42 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,242 bytes |
コンパイル時間 | 1,927 ms |
コンパイル使用メモリ | 179,896 KB |
実行使用メモリ | 26,880 KB |
最終ジャッジ日時 | 2024-09-14 17:16:50 |
合計ジャッジ時間 | 4,231 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
26,752 KB |
testcase_01 | AC | 38 ms
26,752 KB |
testcase_02 | AC | 38 ms
26,624 KB |
testcase_03 | AC | 39 ms
26,752 KB |
testcase_04 | AC | 38 ms
26,752 KB |
testcase_05 | AC | 38 ms
26,624 KB |
testcase_06 | AC | 38 ms
26,752 KB |
testcase_07 | AC | 38 ms
26,752 KB |
testcase_08 | AC | 38 ms
26,880 KB |
testcase_09 | AC | 39 ms
26,624 KB |
testcase_10 | AC | 39 ms
26,624 KB |
testcase_11 | AC | 39 ms
26,752 KB |
testcase_12 | AC | 38 ms
26,752 KB |
testcase_13 | AC | 38 ms
26,752 KB |
testcase_14 | AC | 39 ms
26,624 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 39 ms
26,624 KB |
testcase_18 | WA | - |
testcase_19 | AC | 38 ms
26,624 KB |
testcase_20 | AC | 38 ms
26,624 KB |
testcase_21 | AC | 38 ms
26,624 KB |
testcase_22 | AC | 39 ms
26,624 KB |
testcase_23 | AC | 39 ms
26,624 KB |
testcase_24 | AC | 39 ms
26,624 KB |
testcase_25 | AC | 39 ms
26,496 KB |
testcase_26 | AC | 38 ms
26,752 KB |
testcase_27 | AC | 40 ms
26,752 KB |
testcase_28 | AC | 38 ms
26,752 KB |
testcase_29 | AC | 39 ms
26,752 KB |
testcase_30 | WA | - |
testcase_31 | AC | 38 ms
26,752 KB |
testcase_32 | WA | - |
testcase_33 | AC | 38 ms
26,624 KB |
testcase_34 | WA | - |
ソースコード
#include <bits/stdc++.h> #define whlie while #define pb push_back #define eb emplace_back #define fi first #define se second #define rep(i,N) for(int i = 0; i < (N); i++) #define repr(i,N) for(int i = (N) - 1; i >= 0; i--) #define rep1(i,N) for(int i = 1; i <= (N) ; i++) #define repr1(i,N) for(int i = (N) ; i > 0 ; i--) #define each(x,v) for(auto& x : v) #define all(v) (v).begin(),(v).end() #define sz(v) ((int)(v).size()) #define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++) #define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++) #define ini(...) int __VA_ARGS__; in(__VA_ARGS__) #define inl(...) ll __VA_ARGS__; in(__VA_ARGS__) #define ins(...) string __VA_ARGS__; in(__VA_ARGS__) using namespace std; void solve(); using ll = long long; using vl = vector<ll>; using vi = vector<int>; using vvi = vector< vector<int> >; constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1; struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya; template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; } template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; } template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; } template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; } template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; } template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; } void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);} void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);} template<typename T>void die(T x){out(x); exit(0);} #ifdef NyaanDebug #include "NyaanDebug.h" #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0) #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0) #else #define trc(...) #define trca(...) int main(){solve();} #endif using P = pair<ll,ll>; using vp = vector<P>; constexpr int MOD = /**/ 1000000007; //*/ 998244353; ///////////////// vector<ll> fac,finv,inv; void COMinit(int MAX) { MAX++; fac.resize(MAX , 0); finv.resize(MAX , 0); inv.resize(MAX , 0); fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // nCk combination inline long long COM(int n,int k){ if(n < k || k < 0 || n < 0) return 0; else return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // nPk permutation inline long long PER(int n,int k){ if (n < k || k < 0 || n < 0) return 0; else return (fac[n] * finv[n - k]) % MOD; } // nHk homogeneous polynomial inline long long HGP(int n,int k){ if(n == 0 && k == 0) return 1; //問題依存? else if(n < 1 || k < 0) return 0; else return fac[n + k - 1] * (finv[k] * finv[n - 1] % MOD) % MOD; } // c++17での名前衝突を避けるためdefine #define gcd nyagcd #define lcm nyalcm ll nyagcd(ll x, ll y){ ll z; if(x > y) swap(x,y); while(x){ x = y % (z = x); y = z; } return y; } ll nyalcm(ll x,ll y){ return 1LL * x / gcd(x,y) * y; } void solve(){ COMinit(1001000); ini(N,K); ll ans = 0; ll cur = gcd(N , K); trc(cur); if(cur == 1) die(0); map<ll,int> m; for(ll i=2;i *i <= N;i++){ whlie(cur % i == 0){ m[i]++; cur /= i; } } if(cur != 1) m[cur]++; int x = m.size(); vi memo; each(x,m) memo.eb(x.fi); rep(bit , 1LL << x){ if(bit == 0) continue; ll cur = 1; int cnt = 0; rep(i,x){ if(bit & (1 << i)) cur *= memo[i] , cnt++; } trc(cur , cnt); if(cnt % 2 == 0) ans -= COM(N/cur,K/cur) % MOD; else ans += COM(N/cur , K/cur) % MOD; } out(ans); }