結果

問題 No.491 10^9+1と回文
ユーザー alpha_virginisalpha_virginis
提出日時 2017-03-10 23:46:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,126 bytes
コンパイル時間 1,450 ms
コンパイル使用メモリ 166,436 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-06 14:38:39
合計ジャッジ時間 4,037 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);

template<typename T>
T pow(T x, long n) {
  T res = 1;
  T p = x;
  while( n != 0 ) {
    if( n & 0x01 ) res *= p;
    p *= p;
    n >>= 1;
  }
  return res;
}

// void greedy(long x) {
//   long t = 1000000001;
//   for(long i = t; i <= x; i+=t) {
//     if( 
//   }
  
// }

long f(std::string str, int b, int n) {
  if( n == 0 ) return 0;
  if( n == 1 ) return str[b] - '0' + (b == 0 ? 0 : 1);
  long res = pow(10, n - 1) * std::max(0, str[b] - '0' - (b == 0 ? 1 : -1)) + f(str, b + 1, n - 1);
  dumpl(res);
  return res;
}

int main() {
  long dp[32] = {};
  // dp[1] = 9;
  // dp[2] = 9;
  // dp[3] = 9 * 10;
  // dp[4] = 9 * 10;
  // dp[5] = 9 * 10 * 10;
  for(int i = 0; i < 32; ++i) {
    dp[i] = 9 * pow(10, (i-1)/2);
  }
  
  std::string str;
  std::cin >> str;
  long t = std::stol(str);
  if( t < 1000000001 ) {
    puts("0");
    return 0;
  }
  long low  = t % 1000000000;
  long high = t / 1000000000;
  long m = (int)str.size() - 9;
  long x = f(str, 0, (m + 1) / 2);
  dumpl(m);
  // long x = 0;
  for(int i = 1; i < m; ++i) {
    x += dp[i];
  }
  // for(int i = 1; i < m; ++i) {
  //   x += dp[i];
  // }
  // x += (str[0] - '0') * pow(10, std::max((long)0, (m - 1)/2));
  long res = x;
  if( high > low ) res = std::max(long(0), res - 1);
  printf("%ld\n", res);
  
  return 0;
}
0