結果

問題 No.528 10^9と10^9+7と回文
ユーザー ytftytft
提出日時 2021-03-19 18:39:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 169,376 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 20:17:33
合計ジャッジ時間 3,984 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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


int main(){
    string S;
    cin>>S;
    int p;
    p=S.size();
    vector<int> N(p);
    for(int i=0;i<p;i++){
        N[i]=S[i]-'0';
    }
    long long ans=1;
    long long temp;
    vector<long long> MOD={1000000000,1000000007};
    for(int j=0;j<2;j++){
        ans=1;
        for(int i=0;i<p/2;i++){
            if(N[i]>N[p-1-i]){
                ans=0;
                break;
            }
        }
        temp=1;
        for(int i=(p-1)/2;i>0;i--){
            ans=(ans+temp*N[i])%MOD[j];
            temp=(temp*10)%MOD[j];
        }
        ans=(ans+temp*(N[0]-1))%MOD[j];
        temp=9;
        for(int i=1;i<p;i++){
            ans=(ans+temp)%MOD[j];
            if(i%2==0){
                temp=(temp*10)%MOD[j];
            }
        }
        cout<<ans<<endl;
    }
}
0