結果

問題 No.793 うし数列 2
ユーザー cherrypi59cherrypi59
提出日時 2019-04-18 09:53:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 167,472 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 07:43:28
合計ジャッジ時間 2,895 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;

const lint MOD = (lint)1e9 + 7;
lint pre[65];

lint mod_pow(lint n, lint x){
    lint res = 1;
    while(x){
        if(x & 1) res = res * n % MOD;
        x >>= 1; n = n * n % MOD;
    }
    return res;
}

int main(){
    lint N; cin >> N;

    pre[0] = 3;
    for(int i=1;(1LL<<i)<=N;i++){
        pre[i] = pre[i-1] * mod_pow(10, 1LL<<(i-1)) + pre[i-1];
        pre[i] %= MOD;
    }

    lint ans = mod_pow(10, N), cur = 0;
    for(int i=0;0<N;i++){
        if(N & 1){
            ans += pre[i] * mod_pow(10, cur);
            ans %= MOD; cur += (1LL<<i);
        }
        N >>= 1;
    }

    cout << ans << endl;
    return 0;
}
0