結果
| 問題 | No.1260 たくさんの多項式 |
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2020-10-16 22:21:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 967 ms / 2,000 ms |
| コード長 | 904 bytes |
| 記録 | |
| コンパイル時間 | 2,109 ms |
| コンパイル使用メモリ | 195,124 KB |
| 最終ジャッジ日時 | 2025-01-15 08:39:55 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 61 |
ソースコード
#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;
}
沙耶花