結果

問題 No.164 ちっちゃくないよ!!
ユーザー 👑 obakyanobakyan
提出日時 2019-05-06 10:21:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 71,456 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 11:42:04
合計ジャッジ時間 1,746 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <iomanip>
#include <numeric>
#define L64 long long

int main(void)
{
  int n;
  char a[100];
  std::cin >> n;
  L64 minval = -1;
  for(int i = 0; i < n; i++){
    std::cin >> a;
    int len = (int)strlen(a);
    int digmax = 0;
    for (int j = 0; j < len; j++){
      int digval = 0;
      if(65 <= a[j]) {
        digval = a[j] - 55;
      } else {
        digval = a[j] - 48;
      }
      digmax = std::max(digmax, digval);
    }
    digmax++;
    L64 retval = 0;
    L64 mult = 1;
    for(int j = len - 1; 0 <= j; j--){
      L64 digval = 0;
      if(65 <= a[j]) {
        digval = a[j] - 55;
      } else {
        digval = a[j] - 48;
      }
      retval += mult * digval;
      mult *= (L64)digmax;
    }
    if(i == 0) {minval = retval;}
    else{minval = std::min(minval, retval);}
  }
  std::cout << minval << std::endl;
}
0