結果
問題 | No.890 移調の限られた旋法 |
ユーザー | DAyamaCTF |
提出日時 | 2019-09-20 21:47:04 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 404 ms / 2,000 ms |
コード長 | 1,481 bytes |
コンパイル時間 | 2,231 ms |
コンパイル使用メモリ | 145,424 KB |
実行使用メモリ | 26,992 KB |
最終ジャッジ日時 | 2023-10-12 18:42:56 |
合計ジャッジ時間 | 11,472 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 141 ms
19,924 KB |
testcase_01 | AC | 141 ms
19,748 KB |
testcase_02 | AC | 142 ms
19,748 KB |
testcase_03 | AC | 141 ms
19,700 KB |
testcase_04 | AC | 141 ms
19,760 KB |
testcase_05 | AC | 141 ms
19,744 KB |
testcase_06 | AC | 141 ms
19,640 KB |
testcase_07 | AC | 142 ms
19,804 KB |
testcase_08 | AC | 142 ms
19,632 KB |
testcase_09 | AC | 141 ms
19,700 KB |
testcase_10 | AC | 142 ms
19,628 KB |
testcase_11 | AC | 142 ms
19,700 KB |
testcase_12 | AC | 142 ms
19,872 KB |
testcase_13 | AC | 399 ms
26,888 KB |
testcase_14 | AC | 402 ms
26,764 KB |
testcase_15 | AC | 401 ms
26,920 KB |
testcase_16 | AC | 404 ms
26,992 KB |
testcase_17 | AC | 366 ms
26,000 KB |
testcase_18 | AC | 366 ms
26,284 KB |
testcase_19 | AC | 267 ms
23,080 KB |
testcase_20 | AC | 218 ms
21,676 KB |
testcase_21 | AC | 155 ms
19,868 KB |
testcase_22 | AC | 329 ms
24,952 KB |
testcase_23 | AC | 391 ms
26,356 KB |
testcase_24 | AC | 267 ms
23,180 KB |
testcase_25 | AC | 164 ms
19,988 KB |
testcase_26 | AC | 387 ms
26,492 KB |
testcase_27 | AC | 403 ms
26,572 KB |
testcase_28 | AC | 294 ms
23,788 KB |
testcase_29 | AC | 236 ms
22,156 KB |
testcase_30 | AC | 361 ms
26,164 KB |
testcase_31 | AC | 254 ms
23,064 KB |
testcase_32 | AC | 341 ms
25,712 KB |
testcase_33 | AC | 359 ms
26,028 KB |
testcase_34 | AC | 358 ms
25,964 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rep(i,n) repl(i,0,n) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define mmax(x,y) (x>y?x:y) #define mmin(x,y) (x<y?x:y) #define maxch(x,y) x=mmax(x,y) #define minch(x,y) x=mmin(x,y) #define uni(x) x.erase(unique(all(x)),x.end()) #define exist(x,y) (find(all(x),y)!=x.end()) #define bcnt __builtin_popcountll #define INF 1e16 #define mod 1000000007 ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; } ll mod_pow(ll a,ll n){ ll res=1; while(n>0){ if(n&1)res=res*a%mod; a=a*a%mod; n>>=1; } return res; } bool vis[1000010]; ll res[1000010]; ll fac[1000010],finv[1000010]; ll comb(ll n,ll r){ if(n<0||r<0||n<r)return 0; else return ((fac[n]*finv[r])%mod)*finv[n-r]%mod; } ll N,K; int main(){ cin.tie(0); ios::sync_with_stdio(false); fac[0]=1; rep(i,1000000)fac[i+1]=fac[i]*(i+1)%mod; rep(i,1000001)finv[i]=mod_pow(fac[i],mod-2); cin>>N>>K; repl(i,1,N){ ll g=gcd(N,i); if(vis[g])continue; vis[g]=true; ll A=N/g; ll B=N/A; if(K%A==0){ ll cnt=K/A; res[g]+=comb(B,cnt); res[g]%=mod; } } ll sum=0; for(ll i=1;i<=N;i++){ if(vis[i])(sum+=res[i])%=mod; for(ll j=2*i;j<=N;j+=i)(res[j]+=mod-res[i])%=mod; } cout<<sum<<endl; return 0; }