結果

問題 No.491 10^9+1と回文
ユーザー zimphazimpha
提出日時 2017-03-29 21:33:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,731 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 78,668 KB
実行使用メモリ 52,220 KB
最終ジャッジ日時 2024-07-06 15:09:59
合計ジャッジ時間 9,088 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
50,320 KB
testcase_01 AC 49 ms
50,172 KB
testcase_02 AC 49 ms
50,024 KB
testcase_03 AC 49 ms
50,412 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 46 ms
50,324 KB
testcase_07 AC 48 ms
50,384 KB
testcase_08 WA -
testcase_09 AC 48 ms
50,556 KB
testcase_10 AC 47 ms
50,104 KB
testcase_11 WA -
testcase_12 AC 48 ms
50,368 KB
testcase_13 AC 48 ms
50,080 KB
testcase_14 WA -
testcase_15 AC 49 ms
49,952 KB
testcase_16 AC 46 ms
50,016 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 48 ms
50,412 KB
testcase_21 WA -
testcase_22 AC 49 ms
50,432 KB
testcase_23 WA -
testcase_24 AC 47 ms
50,368 KB
testcase_25 WA -
testcase_26 AC 46 ms
50,408 KB
testcase_27 AC 47 ms
50,464 KB
testcase_28 WA -
testcase_29 AC 49 ms
50,460 KB
testcase_30 WA -
testcase_31 AC 49 ms
50,472 KB
testcase_32 WA -
testcase_33 AC 47 ms
50,432 KB
testcase_34 AC 48 ms
50,436 KB
testcase_35 WA -
testcase_36 AC 46 ms
50,428 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 47 ms
50,456 KB
testcase_40 AC 47 ms
50,024 KB
testcase_41 AC 48 ms
50,436 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 50 ms
50,260 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 47 ms
50,128 KB
testcase_49 AC 47 ms
50,068 KB
testcase_50 AC 48 ms
50,392 KB
testcase_51 WA -
testcase_52 AC 46 ms
50,524 KB
testcase_53 AC 45 ms
50,508 KB
testcase_54 AC 46 ms
50,420 KB
testcase_55 AC 47 ms
50,420 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 56 ms
50,204 KB
testcase_59 WA -
testcase_60 AC 47 ms
50,160 KB
testcase_61 AC 47 ms
50,336 KB
testcase_62 AC 47 ms
50,412 KB
testcase_63 AC 48 ms
50,360 KB
testcase_64 WA -
testcase_65 AC 47 ms
50,500 KB
testcase_66 AC 47 ms
50,472 KB
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 46 ms
50,300 KB
testcase_70 WA -
testcase_71 AC 47 ms
50,388 KB
testcase_72 WA -
testcase_73 AC 47 ms
50,416 KB
testcase_74 WA -
testcase_75 AC 48 ms
49,996 KB
testcase_76 AC 48 ms
50,504 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 48 ms
50,112 KB
testcase_81 AC 48 ms
50,484 KB
testcase_82 AC 49 ms
50,288 KB
testcase_83 WA -
testcase_84 AC 50 ms
50,036 KB
testcase_85 WA -
testcase_86 AC 46 ms
50,488 KB
testcase_87 WA -
testcase_88 AC 49 ms
50,356 KB
testcase_89 AC 49 ms
50,504 KB
testcase_90 AC 47 ms
50,496 KB
testcase_91 WA -
testcase_92 AC 49 ms
50,156 KB
testcase_93 WA -
testcase_94 WA -
testcase_95 AC 48 ms
50,372 KB
testcase_96 AC 46 ms
50,268 KB
testcase_97 AC 47 ms
50,400 KB
testcase_98 WA -
testcase_99 AC 49 ms
50,360 KB
testcase_100 WA -
testcase_101 AC 45 ms
50,524 KB
testcase_102 AC 49 ms
50,468 KB
testcase_103 AC 49 ms
50,068 KB
testcase_104 WA -
testcase_105 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Chiaki.Hoshinomori
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task491 solver = new Task491();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task491 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            n = n / 1000000001;
            if (n == 0) {
                out.println(0);
            } else {
                int ret = 0;
                char[] s = new Long(n).toString().toCharArray();
                int[] pw = new int[10];
                pw[0] = 1;
                for (int i = 1; i < 10; i++) {
                    pw[i] = pw[i - 1] * 10;
                }
                for (int i = 1; i < s.length; ++i) {
                    ret += 9 * pw[(i + 1) / 2 - 1];
                }
                int now = 0;
                for (int i = 0; i < (s.length + 1) / 2; i++) {
                    now = now * 10 + s[i] - '0';
                    int coef = s[i] - '0';
                    int rest = (s.length + 1) / 2 - (i + 1);
                    if (i == 0) --coef;
                    ret += coef * pw[rest];
                }
                for (int i = 0; i < s.length - (s.length + 1) / 2; ++i) {
                    now += pw[i] * (s[i] - '0');
                }
                if (now <= n) ++ret;
                out.println(ret);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

0