結果
問題 |
No.644 G L C C D M
|
ユーザー |
![]() |
提出日時 | 2025-09-18 20:48:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,350 bytes |
コンパイル時間 | 2,878 ms |
コンパイル使用メモリ | 275,508 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-18 20:48:06 |
合計ジャッジ時間 | 4,408 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 WA * 2 |
ソースコード
#include<bits/stdc++.h> #define int long long using namespace std; #define fi first #define sc second #define pii pair<int,int> #define pdd pair<double,double> #define pb push_back #define umap unordered_map #define mset multiset #define pq priority_queue #define ull unsigned long long #define i128 __int128 #define ld long double #define fixs fixed<<setprecision #define FileIn(x) freopen(x".in","r",stdin) #define FileOut(x) freopen(x".out","w",stdout) #define FileIO(x) FileIn(x),FileOut(x); const int maxn=1e5+10; const int mod=1e9+7; int n,m,k,res,p[maxn],mu[maxn],cnt,vis[maxn],sum[maxn]; void pre(){ mu[1]=1; for(int i=2;i<=1e5;i++){ if(!vis[i]) p[++cnt]=i,mu[i]=-1; for(int j=1;j<=cnt&&i*p[j]<=1e5;j++){ vis[i*p[j]]=1; if(i%p[j]==0){ mu[i*p[j]]=0; break; } mu[i*p[j]]=-mu[i]; } } for(int i=1;i<=1e5;i++) sum[i]=sum[i-1]+mu[i]; } void solve(){ cin>>n>>m,k=n/m; if(m>=n) return cout<<0<<endl,void(); for(int l=1,r;l<=k;l=r+1) r=k/(k/l),res=(res+(sum[r]-sum[l-1])*(k/l)%mod*(k/l)%mod)%mod; res--; for(int i=1;i<=n-2;i++) res=(res*i)%mod; cout<<res<<endl; } signed main(){ ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); int t=1; // cin>>t; pre(); while(t--) solve(); return 0; } /* Samples input: output: THINGS TODO: ??freopen??????? ???? ???????????? */