結果
| 問題 |
No.644 G L C C D M
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-09-22 16:27:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 718 bytes |
| コンパイル時間 | 1,669 ms |
| コンパイル使用メモリ | 194,360 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-22 16:27:05 |
| 合計ジャッジ時間 | 2,820 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+10,mod=1e9+7;
int n,m,cnt,f=1ll,ans;
int pr[maxn],phi[maxn];
bool vis[maxn];
void pre()
{
phi[1]=1;
for(int i=2;i<=1e5;i++)
{
if(!vis[i]) pr[++cnt]=i,phi[i]=i-1;
for(int j=1;j<=cnt&&i*pr[j]<=1e5;j++)
{
vis[i*pr[j]]=1,phi[i*pr[j]]=phi[i]*(pr[j]-1);
if(i%pr[j]==0)
{
phi[i*pr[j]]=phi[i]*pr[j];
break;
}
}
}
}
signed main()
{
// freopen("gcdlcm.in","r",stdin);
// freopen("gcdlcm.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
pre();
cin>>n>>m;
for(int i=1;i<=n-2;i++) f=f*i%mod;
for(int i=2;i<=n/m;i++) ans=(ans+f*phi[i]%mod)%mod;
cout<<ans*2%mod<<endl;
}
vjudge1