結果

問題 No.491 10^9+1と回文
ユーザー zimphazimpha
提出日時 2017-03-29 21:33:38
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,731 bytes
コンパイル時間 2,053 ms
コンパイル使用メモリ 75,000 KB
実行使用メモリ 51,896 KB
最終ジャッジ日時 2023-09-20 20:19:19
合計ジャッジ時間 10,832 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,584 KB
testcase_01 AC 43 ms
49,452 KB
testcase_02 AC 43 ms
49,392 KB
testcase_03 AC 44 ms
49,808 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 43 ms
49,308 KB
testcase_07 AC 44 ms
49,408 KB
testcase_08 WA -
testcase_09 AC 44 ms
49,380 KB
testcase_10 AC 44 ms
49,792 KB
testcase_11 WA -
testcase_12 AC 44 ms
49,324 KB
testcase_13 AC 43 ms
49,260 KB
testcase_14 WA -
testcase_15 AC 44 ms
49,440 KB
testcase_16 AC 44 ms
49,252 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 43 ms
49,468 KB
testcase_21 WA -
testcase_22 AC 43 ms
49,400 KB
testcase_23 WA -
testcase_24 AC 43 ms
49,472 KB
testcase_25 WA -
testcase_26 AC 44 ms
49,252 KB
testcase_27 AC 43 ms
47,468 KB
testcase_28 WA -
testcase_29 AC 43 ms
49,296 KB
testcase_30 WA -
testcase_31 AC 43 ms
49,392 KB
testcase_32 WA -
testcase_33 AC 43 ms
49,348 KB
testcase_34 AC 43 ms
49,616 KB
testcase_35 WA -
testcase_36 AC 43 ms
49,312 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 43 ms
49,340 KB
testcase_40 AC 43 ms
49,368 KB
testcase_41 AC 42 ms
49,440 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 42 ms
49,256 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 43 ms
49,532 KB
testcase_49 AC 42 ms
49,436 KB
testcase_50 AC 43 ms
49,380 KB
testcase_51 WA -
testcase_52 AC 43 ms
49,380 KB
testcase_53 AC 45 ms
49,552 KB
testcase_54 AC 43 ms
49,236 KB
testcase_55 AC 43 ms
49,788 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 43 ms
49,604 KB
testcase_59 WA -
testcase_60 AC 43 ms
49,312 KB
testcase_61 AC 42 ms
49,304 KB
testcase_62 AC 42 ms
49,408 KB
testcase_63 AC 42 ms
49,440 KB
testcase_64 WA -
testcase_65 AC 43 ms
49,256 KB
testcase_66 AC 43 ms
49,556 KB
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 44 ms
49,384 KB
testcase_70 WA -
testcase_71 AC 43 ms
49,480 KB
testcase_72 WA -
testcase_73 AC 43 ms
49,320 KB
testcase_74 WA -
testcase_75 AC 43 ms
49,420 KB
testcase_76 AC 43 ms
49,508 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 43 ms
47,720 KB
testcase_81 AC 44 ms
49,556 KB
testcase_82 AC 43 ms
49,464 KB
testcase_83 WA -
testcase_84 AC 43 ms
49,240 KB
testcase_85 WA -
testcase_86 AC 43 ms
49,576 KB
testcase_87 WA -
testcase_88 AC 43 ms
49,260 KB
testcase_89 AC 43 ms
49,484 KB
testcase_90 AC 42 ms
49,456 KB
testcase_91 WA -
testcase_92 AC 43 ms
49,492 KB
testcase_93 WA -
testcase_94 WA -
testcase_95 AC 44 ms
49,320 KB
testcase_96 AC 43 ms
49,420 KB
testcase_97 AC 42 ms
49,480 KB
testcase_98 WA -
testcase_99 AC 43 ms
49,408 KB
testcase_100 WA -
testcase_101 AC 42 ms
47,292 KB
testcase_102 AC 43 ms
49,504 KB
testcase_103 AC 43 ms
49,300 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