結果

問題 No.1260 たくさんの多項式
ユーザー SSRSSSRS
提出日時 2020-10-16 22:02:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,117 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 166,224 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 03:08:06
合計ジャッジ時間 8,155 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 27 ms
4,380 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
long long ap(long long a, long long b){
  return (a + b) % MOD * (b - a + 1) % MOD * modinv(2) % MOD;
}
int main(){
  long long N;
  cin >> N;
  long long ans = 0;
  for (long long i = 2; i <= N; i++){
    long long N2 = N;
    int cnt = 0;
    long long sum = 0;
    while (N2 > 0){
      cnt++;
      sum += N2 % i;
      N2 /= i;
    }
    if (cnt >= 3){
      ans += sum;
      ans %= MOD;
    } else {
      break;
    }
  }
  for (long long i = 1; i <= N; i++){
    long long mn = N / (i + 1) + 1;
    long long mx = N / i;
    if (i >= mn){
      break;
    }
    long long sum = N % MOD * ((mx - mn + 1) % MOD) % MOD - i * ap(mn, mx) % MOD;
    if (sum < 0){
      sum += MOD;
    }
    ans += sum;
    ans += i * ((mx - mn + 1) % MOD) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
0