結果
| 問題 |
No.644 G L C C D M
|
| コンテスト | |
| ユーザー |
Pulmn
|
| 提出日時 | 2017-04-21 19:57:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 484 bytes |
| コンパイル時間 | 448 ms |
| コンパイル使用メモリ | 59,968 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-20 05:11:22 |
| 合計ジャッジ時間 | 1,603 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const int MAX_N=100005;
const ll mod=1e9+7;
vl Euler_Phi(){
vl e(MAX_N);
for(int i=0;i<MAX_N;i++) e[i]=i;
for(int i=2;i<MAX_N;i++) if(e[i]==i){
for(int j=i;j<MAX_N;j+=i) e[j]=e[j]/i*(i-1);
}
return e;
}
int N,M;
int main(){
cin>>N>>M;
vl e=Euler_Phi();
ll res=0;
for(int i=2;i<=N/M;i++) (res+=2*e[i])%=mod;
for(int i=1;i<N-1;i++) (res*=i)%=mod;
cout<<res<<endl;
}
Pulmn