結果

問題 No.1260 たくさんの多項式
ユーザー carrot46carrot46
提出日時 2020-10-16 22:51:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 2,844 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 166,372 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 04:38:07
合計ジャッジ時間 6,148 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
4,376 KB
testcase_01 AC 35 ms
4,376 KB
testcase_02 AC 35 ms
4,376 KB
testcase_03 AC 35 ms
4,380 KB
testcase_04 AC 35 ms
4,376 KB
testcase_05 AC 35 ms
4,376 KB
testcase_06 AC 35 ms
4,376 KB
testcase_07 AC 34 ms
4,376 KB
testcase_08 AC 35 ms
4,380 KB
testcase_09 AC 35 ms
4,376 KB
testcase_10 AC 35 ms
4,376 KB
testcase_11 AC 34 ms
4,376 KB
testcase_12 AC 34 ms
4,376 KB
testcase_13 AC 35 ms
4,380 KB
testcase_14 AC 35 ms
4,376 KB
testcase_15 AC 34 ms
4,376 KB
testcase_16 AC 35 ms
4,380 KB
testcase_17 AC 34 ms
4,376 KB
testcase_18 AC 35 ms
4,380 KB
testcase_19 AC 34 ms
4,380 KB
testcase_20 AC 61 ms
4,376 KB
testcase_21 AC 40 ms
4,380 KB
testcase_22 AC 56 ms
4,376 KB
testcase_23 AC 51 ms
4,376 KB
testcase_24 AC 52 ms
4,380 KB
testcase_25 AC 47 ms
4,376 KB
testcase_26 AC 50 ms
4,380 KB
testcase_27 AC 47 ms
4,380 KB
testcase_28 AC 60 ms
4,376 KB
testcase_29 AC 52 ms
4,376 KB
testcase_30 AC 44 ms
4,380 KB
testcase_31 AC 52 ms
4,380 KB
testcase_32 AC 51 ms
4,380 KB
testcase_33 AC 48 ms
4,376 KB
testcase_34 AC 59 ms
4,380 KB
testcase_35 AC 43 ms
4,380 KB
testcase_36 AC 43 ms
4,376 KB
testcase_37 AC 52 ms
4,380 KB
testcase_38 AC 54 ms
4,376 KB
testcase_39 AC 59 ms
4,380 KB
testcase_40 AC 51 ms
4,376 KB
testcase_41 AC 57 ms
4,376 KB
testcase_42 AC 50 ms
4,380 KB
testcase_43 AC 58 ms
4,376 KB
testcase_44 AC 49 ms
4,376 KB
testcase_45 AC 47 ms
4,380 KB
testcase_46 AC 47 ms
4,376 KB
testcase_47 AC 50 ms
4,376 KB
testcase_48 AC 37 ms
4,376 KB
testcase_49 AC 45 ms
4,376 KB
testcase_50 AC 39 ms
4,376 KB
testcase_51 AC 58 ms
4,380 KB
testcase_52 AC 41 ms
4,380 KB
testcase_53 AC 44 ms
4,376 KB
testcase_54 AC 60 ms
4,376 KB
testcase_55 AC 61 ms
4,380 KB
testcase_56 AC 45 ms
4,376 KB
testcase_57 AC 50 ms
4,376 KB
testcase_58 AC 43 ms
4,376 KB
testcase_59 AC 52 ms
4,380 KB
testcase_60 AC 62 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<48);

template <unsigned long long mod > class modint{
public:
    ll x;
    constexpr modint(){x = 0;}
    constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){}
    constexpr modint set_raw(ll _x){
        //_x in [0, mod)
        x = _x;
        return *this;
    }
    constexpr modint operator-(){
        return x == 0 ? 0 : mod - x;
    }
    constexpr modint& operator+=(const modint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr modint operator+(const modint& a) const{
        return modint(*this) += a;
    }
    constexpr modint& operator-=(const modint& a){
        if((x -= a.x) < 0) x += mod;
        return *this;
    }
    constexpr modint operator-(const modint& a) const{
        return modint(*this) -= a;
    }
    constexpr modint& operator*=(const modint& a){
        (x *= a.x)%=mod;
        return *this;
    }
    constexpr modint operator*(const modint& a) const{
        return modint(*this) *= a;
    }
    constexpr modint pow(unsigned long long pw) const{
        modint res(1), comp(*this);
        while(pw){
            if(pw&1) res *= comp;
            comp *= comp;
            pw >>= 1;
        }
        return res;
    }
    //以下、modが素数のときのみ
    constexpr modint inv() const{
        if(x == 2) return (mod + 1) >> 1;
        return modint(*this).pow(mod - 2);
    }
    constexpr modint& operator/=(const modint &a){
        (x *= a.inv().x)%=mod;
        return *this;
    }
    constexpr modint operator/(const modint &a) const{
        return modint(*this) /= a;
    }
};
#define mod2 1000000007
using mint = modint<mod2>;

ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
using vm = vector<mint>;

mint tinv((mod2 + 1)>>1);

mint sum(ll l, ll r){
    //sum of [l, r]
    if(l > r) return 0;
    return mint(r + l) * (r - l + 1) * tinv;
}

int main() {
    cin>>N;
    ll base = 1000010;
    //ll base = 48;
    mint res(0);
    reps(i, 2, min(N, base) + 1){
        ll temp = N;
        while(temp){
            res += temp % i;
            temp /= i;
        }
    }
    if(N > base){
        res += mint(N) * (N - base);
        reps(k, 1, base) {
            //cout<<res<<endl;
            res -= sum(base, (N / k) - 1);
        }
    }
    cout<<res<<endl;
}
0