結果

問題 No.1260 たくさんの多項式
ユーザー 沙耶花沙耶花
提出日時 2020-10-16 22:21:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 903 ms / 2,000 ms
コード長 904 bytes
コンパイル時間 2,182 ms
コンパイル使用メモリ 200,120 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 03:40:05
合計ジャッジ時間 27,394 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 7 ms
4,380 KB
testcase_02 AC 6 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 7 ms
4,376 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 8 ms
4,384 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 8 ms
4,376 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 AC 7 ms
4,380 KB
testcase_20 AC 844 ms
4,380 KB
testcase_21 AC 218 ms
4,376 KB
testcase_22 AC 732 ms
4,380 KB
testcase_23 AC 590 ms
4,380 KB
testcase_24 AC 605 ms
4,376 KB
testcase_25 AC 474 ms
4,380 KB
testcase_26 AC 636 ms
4,380 KB
testcase_27 AC 457 ms
4,376 KB
testcase_28 AC 814 ms
4,376 KB
testcase_29 AC 588 ms
4,376 KB
testcase_30 AC 359 ms
4,376 KB
testcase_31 AC 615 ms
4,376 KB
testcase_32 AC 623 ms
4,380 KB
testcase_33 AC 489 ms
4,380 KB
testcase_34 AC 798 ms
4,380 KB
testcase_35 AC 342 ms
4,376 KB
testcase_36 AC 308 ms
4,376 KB
testcase_37 AC 599 ms
4,380 KB
testcase_38 AC 678 ms
4,380 KB
testcase_39 AC 803 ms
4,380 KB
testcase_40 AC 595 ms
4,380 KB
testcase_41 AC 762 ms
4,384 KB
testcase_42 AC 548 ms
4,376 KB
testcase_43 AC 794 ms
4,380 KB
testcase_44 AC 488 ms
4,380 KB
testcase_45 AC 462 ms
4,380 KB
testcase_46 AC 426 ms
4,380 KB
testcase_47 AC 541 ms
4,376 KB
testcase_48 AC 100 ms
4,376 KB
testcase_49 AC 402 ms
4,380 KB
testcase_50 AC 199 ms
4,376 KB
testcase_51 AC 783 ms
4,380 KB
testcase_52 AC 253 ms
4,380 KB
testcase_53 AC 371 ms
4,376 KB
testcase_54 AC 903 ms
4,376 KB
testcase_55 AC 856 ms
4,380 KB
testcase_56 AC 373 ms
4,380 KB
testcase_57 AC 562 ms
4,376 KB
testcase_58 AC 336 ms
4,376 KB
testcase_59 AC 595 ms
4,376 KB
testcase_60 AC 846 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

mint ans = 0;
long long N;

void go(long long a,long long b,long long n){
	a+=b;
	mint temp = a;
	temp *= n;
	temp /= 2;
	ans += temp;
}

void check(long long now){
	while(now<=N){
		long long ok = now;
		long long ng = N+1;
		while(ng-ok>1){
			long long mid = (ok+ng)/2;
			if(N/now != N/mid)ng = mid;
			else ok = mid;
		}
		long long cnt = ok-now+1;
		mint temp = N/now;
		temp *= cnt;
		ans += temp;
		go(N%now,N%ok,cnt);
		now = ok+1;
	}
}

int main(){	
	
	
	cin>>N;
	
	for(long long i=2;true;i++){
		if(i*i>N){
			check(i);
			break;
		}
		else{
			long long temp = N;
			while(temp!=0){
				ans += temp%i;
				temp /= i;
			}
		}
	}
	
	cout<<ans.val()<<endl;
	
    return 0;
}

0