結果

問題 No.644 G L C C D M
ユーザー どららどらら
提出日時 2018-02-02 23:41:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 950 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 163,588 KB
実行使用メモリ 4,716 KB
最終ジャッジ日時 2023-08-30 02:31:52
合計ジャッジ時間 2,745 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,560 KB
testcase_01 AC 6 ms
4,608 KB
testcase_02 AC 6 ms
4,520 KB
testcase_03 AC 7 ms
4,536 KB
testcase_04 AC 7 ms
4,588 KB
testcase_05 AC 6 ms
4,592 KB
testcase_06 AC 6 ms
4,652 KB
testcase_07 AC 6 ms
4,600 KB
testcase_08 AC 6 ms
4,580 KB
testcase_09 AC 6 ms
4,660 KB
testcase_10 AC 6 ms
4,588 KB
testcase_11 AC 6 ms
4,648 KB
testcase_12 AC 6 ms
4,612 KB
testcase_13 AC 6 ms
4,532 KB
testcase_14 AC 6 ms
4,540 KB
testcase_15 AC 6 ms
4,512 KB
testcase_16 AC 6 ms
4,532 KB
testcase_17 AC 6 ms
4,516 KB
testcase_18 AC 7 ms
4,544 KB
testcase_19 AC 7 ms
4,532 KB
testcase_20 AC 6 ms
4,512 KB
testcase_21 AC 7 ms
4,680 KB
testcase_22 AC 7 ms
4,716 KB
testcase_23 AC 7 ms
4,512 KB
testcase_24 AC 7 ms
4,588 KB
testcase_25 AC 7 ms
4,556 KB
testcase_26 AC 6 ms
4,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
int a[100005], b[100005];
int dp[100005];
void phi_all(int N) {
  rep(i, N+1) {
    a[i] = 1;
    b[i] = i;
  }
  rep(k, N+1) {
    if (b[k] < 2) continue;
    for(int n = k; n <= N; n += k) {
      for(int m = k-1; b[n]%k == 0; m = k) {
        a[n] *= m;
        b[n] /= k;
      }
    }
  }
  // a[n] == phi(n), b[n] == 1
}

int main(){
  int N, M;
  cin >> N >> M;
  phi_all(100001);
  REP(i,2,100001){
    dp[i] = dp[i-1] + a[i];
    dp[i] %= MOD;
  }
  
  ll pp = 1;
  rep(i,N-2){
    pp *= i+1;
    pp %= MOD;
  }

  ll ret = 0;
  ret += (2 * dp[N/M] * pp) % MOD;
  ret %= MOD;

  cout << ret << endl;
  
  return 0;
}
0