結果

問題 No.793 うし数列 2
ユーザー rtia_iidxrtia_iidx
提出日時 2019-02-22 22:31:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 993 bytes
コンパイル時間 853 ms
コンパイル使用メモリ 97,936 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 19:54:57
合計ジャッジ時間 1,675 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 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: 関数 ‘int main()’ 内:
main.cpp:60:29: 警告: ‘tmp’ may be used uninitialized [-Wmaybe-uninitialized]
   60 |     cout << (ans + (tmp + z)*2)%MOD << endl;
      |                    ~~~~~~~~~^~
main.cpp:54:8: 備考: ‘tmp’ はここで定義されています
   54 |     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;

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 = (ans * 10000 + 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