結果

問題 No.793 うし数列 2
ユーザー rtia_iidxrtia_iidx
提出日時 2019-02-22 22:24:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,050 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 89,088 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-16 19:39:33
合計ジャッジ時間 1,771 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,504 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:63:29: warning: ‘tmp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout << (ans + (tmp + z)*2)%MOD << endl;
                    ~~~~~~~~~^~

ソースコード

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;

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;

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

    ll ans = 0;
    
    if(x <= 100000){
        ans = 1;
    }

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

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

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