結果

問題 No.793 うし数列 2
ユーザー rtia_iidxrtia_iidx
提出日時 2019-02-22 22:48:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,676 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 99,228 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 21:11:39
合計ジャッジ時間 2,179 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,384 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,384 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,384 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 4 ms
4,384 KB
testcase_11 AC 4 ms
4,384 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 4 ms
4,384 KB
testcase_14 AC 3 ms
4,384 KB
testcase_15 AC 4 ms
4,384 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 3 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:100:25: 警告: ‘tmp’ may be used uninitialized [-Wmaybe-uninitialized]
  100 |     cout << (ans + (tmp)*2)%MOD << endl;
      |                    ~~~~~^~
main.cpp:94:8: 備考: ‘tmp’ はここで定義されています
   94 |     ll tmp;
      |        ^~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll t){
    ll ret = 1;

    while(t > 0){
        if(t&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        t >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;

    ll x = n%(MOD-1);

    ll y = (((MOD)*(MOD-1))/2)%MOD;

    ll z = ((((n/(MOD-1))%MOD)*y)%MOD);

    ll base = 1;
    ll t = 1;

    for(int i = 1; i < 100000; i++){
        base = (base*10 + 1)%MOD;
        t++;
    }

    ll base2 = base;

    ll sr = mypow(10,100000);

    for(int i = 1; i < 100000; i++){
        base2 = (base2 * sr + base)%MOD;
    }

    ll sr2 = mypow(10,10000000000);

    ll base3 = base2;
    for(int i = 1; i < 10000; i++){
        base3 = (base3 * sr2 + base2)%MOD;
    }

    ll ans = 1;

    ll sr3 = mypow(10,100000000000000);

    while(n > 100000000000000){
        n -= 100000000000000;
        ans = (ans * sr3 + base3)%MOD;
    }

    while(n > 10000000000){
        n-= 10000000000;
        ans = (ans * sr2 + base2)%MOD;
    }



    while(n > 100000){
        n -= 100000;
        ans = (ans * sr + base)%MOD;
    }

    ll tmp;
    for(int i = 0; i < n; i++){
        tmp = ans;
        ans = (ans*10 + 1)%MOD;
    }

    cout << (ans + (tmp)*2)%MOD << endl;
    
    return 0;
}
0