結果

問題 No.491 10^9+1と回文
ユーザー cherrypi59cherrypi59
提出日時 2019-04-15 12:26:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 168,300 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 06:34:54
合計ジャッジ時間 4,324 ms
ジャッジサーバーID
(参考情報)
judge9 / 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 WA -
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
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 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,348 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 WA -
testcase_41 AC 2 ms
4,348 KB
testcase_42 WA -
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 2 ms
4,348 KB
testcase_47 WA -
testcase_48 AC 2 ms
4,348 KB
testcase_49 WA -
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 1 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 WA -
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 2 ms
4,348 KB
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 2 ms
4,348 KB
testcase_61 AC 2 ms
4,348 KB
testcase_62 AC 2 ms
4,348 KB
testcase_63 AC 2 ms
4,348 KB
testcase_64 AC 2 ms
4,348 KB
testcase_65 AC 2 ms
4,348 KB
testcase_66 AC 2 ms
4,348 KB
testcase_67 AC 2 ms
4,348 KB
testcase_68 AC 2 ms
4,348 KB
testcase_69 WA -
testcase_70 AC 2 ms
4,348 KB
testcase_71 WA -
testcase_72 AC 2 ms
4,348 KB
testcase_73 AC 2 ms
4,348 KB
testcase_74 AC 2 ms
4,348 KB
testcase_75 AC 2 ms
4,348 KB
testcase_76 AC 1 ms
4,348 KB
testcase_77 AC 2 ms
4,348 KB
testcase_78 AC 1 ms
4,348 KB
testcase_79 WA -
testcase_80 WA -
testcase_81 AC 2 ms
4,348 KB
testcase_82 AC 1 ms
4,348 KB
testcase_83 AC 2 ms
4,348 KB
testcase_84 AC 2 ms
4,348 KB
testcase_85 AC 2 ms
4,348 KB
testcase_86 AC 2 ms
4,348 KB
testcase_87 AC 2 ms
4,348 KB
testcase_88 WA -
testcase_89 AC 2 ms
4,348 KB
testcase_90 AC 2 ms
4,348 KB
testcase_91 WA -
testcase_92 AC 2 ms
4,348 KB
testcase_93 AC 2 ms
4,348 KB
testcase_94 WA -
testcase_95 AC 2 ms
4,348 KB
testcase_96 AC 2 ms
4,348 KB
testcase_97 AC 2 ms
4,348 KB
testcase_98 WA -
testcase_99 AC 2 ms
4,348 KB
testcase_100 AC 2 ms
4,348 KB
testcase_101 AC 1 ms
4,348 KB
testcase_102 AC 1 ms
4,348 KB
testcase_103 AC 2 ms
4,348 KB
testcase_104 AC 2 ms
4,348 KB
testcase_105 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

lint p[10];

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

    p[0] = 1;
    for(int i=1;i<10;i++) p[i] = p[i-1] * 10;

    N = N / lint(1e9+1);
    string S = to_string(N);

    lint ans = 0;
    int k = S.size();
    for(int i=1;i<k;i++) ans += 9 * p[(i-1)/2];

    for(int i=2;i<=(k+1)/2;i++) if(S[i-1]!='0' and S[k-i]!='0') ans += (S[i-1]-'0') * p[(k-2*i+1)/2];
    if(S[0]!='0' and S[k-1]!='0') ans += (S[0]-'1') * p[(k-1)/ 2];

    bool ok = true;
    for(int i=(k+1)/2-1;0<=i;i--){
        if(S[i]<S[k-i-1]) {ans++, ok = false; break;}
        if(S[i]>S[k-i-1]) {ok = false; break;}
    }
    if(ok) ans++;

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