結果

問題 No.1260 たくさんの多項式
ユーザー msm1993msm1993
提出日時 2020-10-23 15:41:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 1,464 ms
コンパイル使用メモリ 165,352 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 15:27:04
合計ジャッジ時間 6,047 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 78 ms
4,380 KB
testcase_21 AC 24 ms
4,376 KB
testcase_22 AC 69 ms
4,376 KB
testcase_23 AC 56 ms
4,380 KB
testcase_24 AC 58 ms
4,380 KB
testcase_25 AC 46 ms
4,380 KB
testcase_26 AC 55 ms
4,376 KB
testcase_27 AC 44 ms
4,376 KB
testcase_28 AC 76 ms
4,380 KB
testcase_29 AC 57 ms
4,380 KB
testcase_30 AC 36 ms
4,376 KB
testcase_31 AC 58 ms
4,380 KB
testcase_32 AC 57 ms
4,376 KB
testcase_33 AC 47 ms
4,380 KB
testcase_34 AC 74 ms
4,376 KB
testcase_35 AC 34 ms
4,380 KB
testcase_36 AC 31 ms
4,376 KB
testcase_37 AC 58 ms
4,376 KB
testcase_38 AC 63 ms
4,380 KB
testcase_39 AC 75 ms
4,380 KB
testcase_40 AC 57 ms
4,376 KB
testcase_41 AC 71 ms
4,376 KB
testcase_42 AC 53 ms
4,376 KB
testcase_43 AC 74 ms
4,380 KB
testcase_44 AC 48 ms
4,380 KB
testcase_45 AC 46 ms
4,376 KB
testcase_46 AC 42 ms
4,376 KB
testcase_47 AC 52 ms
4,376 KB
testcase_48 AC 12 ms
4,380 KB
testcase_49 AC 40 ms
4,380 KB
testcase_50 AC 21 ms
4,376 KB
testcase_51 AC 75 ms
4,376 KB
testcase_52 AC 27 ms
4,380 KB
testcase_53 AC 35 ms
4,380 KB
testcase_54 AC 76 ms
4,380 KB
testcase_55 AC 79 ms
4,376 KB
testcase_56 AC 38 ms
4,376 KB
testcase_57 AC 54 ms
4,376 KB
testcase_58 AC 34 ms
4,376 KB
testcase_59 AC 57 ms
4,376 KB
testcase_60 AC 80 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define INF 1e18
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int inf = (int)1e9; 

const ll N = 1000000007;
//const ll N = 998244353;

ll Pow(ll x,ll power,ll r){
	ll res = 1;
	ll k = power;
	ll y = x%r;
	while (k) {
		if (k & 1)res = (res*y) % r;
		y = (y%r*y%N) % r;
		k /= 2;
	}
	return res;
}

int main(void){
    ll n;
    cin>>n;
    ll I = 2;
    ll ans = 0;
    for(;I*I<=n;I++){
        ll t = n;
        for(;;){
            ans= (ans+t%I)%N;
            t=t/I;
            if(t<I){
                ans=(ans+t)%N;
                break;
            }
        }
    }
    ll level = n;
    ll INV = Pow(2LL,N-2,N);
    for(ll i=1;i<=I;i++){
        //cout<<ans<<endl;
        ll t = n/i;
        if(t < I)continue;
        ll s = n/(i+1);
        ll l = (level-s)%N;
        ans = ((l*i)%N+ans+N)%N;
        ll r1 = n%(level);
        ll r2 = n%(s+1);
        ll r = (r1+r2)%N;
        ll tmp = (l*r)%N;
        tmp = (tmp*INV)%N;
        ans = (ans+tmp)%N;
        ans = (ans+N)%N;
        level = s;
    }
    cout<<ans<<endl;
    return 0;
}
0