結果

問題 No.491 10^9+1と回文
ユーザー tnakao0123tnakao0123
提出日時 2017-03-11 23:35:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,274 bytes
コンパイル時間 1,150 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-06 19:18:05
合計ジャッジ時間 5,128 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,388 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 1 ms
4,380 KB
testcase_32 WA -
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 WA -
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 WA -
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 2 ms
4,380 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 WA -
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 WA -
testcase_59 AC 1 ms
4,380 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 1 ms
4,376 KB
testcase_64 WA -
testcase_65 AC 1 ms
4,380 KB
testcase_66 AC 1 ms
4,380 KB
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 2 ms
4,380 KB
testcase_70 AC 2 ms
4,380 KB
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 AC 1 ms
4,380 KB
testcase_75 AC 1 ms
4,380 KB
testcase_76 AC 1 ms
4,380 KB
testcase_77 AC 1 ms
4,380 KB
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 1 ms
4,380 KB
testcase_81 AC 1 ms
4,380 KB
testcase_82 AC 1 ms
4,380 KB
testcase_83 AC 1 ms
4,380 KB
testcase_84 AC 1 ms
4,380 KB
testcase_85 WA -
testcase_86 AC 2 ms
4,380 KB
testcase_87 WA -
testcase_88 AC 2 ms
4,376 KB
testcase_89 AC 2 ms
4,380 KB
testcase_90 WA -
testcase_91 WA -
testcase_92 AC 1 ms
4,380 KB
testcase_93 WA -
testcase_94 WA -
testcase_95 AC 1 ms
4,380 KB
testcase_96 AC 1 ms
4,380 KB
testcase_97 AC 1 ms
4,380 KB
testcase_98 WA -
testcase_99 AC 2 ms
4,380 KB
testcase_100 WA -
testcase_101 WA -
testcase_102 AC 2 ms
4,380 KB
testcase_103 AC 2 ms
4,380 KB
testcase_104 WA -
testcase_105 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 491.cc: No.491 10^9+1と回文 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

int ts[10], es[10], ds[10];

/* main */

int main() {
  ts[0] = 1;
  for (int i = 1; i <= 9; i++) ts[i] = ts[i - 1] * 10;
  es[0] = 1;
  es[1] = es[2] = 9;
  for (int i = 3; i <= 9; i++) es[i] = es[i - 2] * 10;
  //for (int i = 0; i <= 9; i++) printf("es[%d]=%d\n", i, es[i]);

  ll n;
  cin >> n;

  ll m = n / 1000000000;
  if (m > n % 1000000000) m--;
  //printf("m=%lld\n", m);

  int k = 0;
  while (m > 0) {
    ds[k++] = m % 10;
    m /= 10;
  }
  //printf("k=%d\n", k);

  int sum = 0;
  for (int i = 1; i < k; i++) sum += es[i];

  for (int i0 = k - 1, i1 = 0; i0 >= i1; i0--, i1++) {
    sum += ((i1 == 0) ? ds[i0] - 1 : ds[i0]) * ts[(i0 - i1) / 2];
    if (ds[i0] > ds[i1]) break;
    if (i0 - i1 <= 1) sum++;
  }
  printf("%d\n", sum);
  return 0;
}
0