結果

問題 No.979 Longest Divisor Sequence
ユーザー noshi91noshi91
提出日時 2019-10-07 22:55:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,612 bytes
コンパイル時間 773 ms
コンパイル使用メモリ 68,732 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 01:19:51
合計ジャッジ時間 1,901 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <limits>

namespace checker {

std::string c_to_str(const int c) {
  if (c == '\n') {
    return "'\n'";
  }
  if (c == std::char_traits<char>::eof()) {
    return "eof";
  }
  return std::string({'\'', char(c), '\''});
}

int c_scan() { return std::cin.get(); }

template <class SignedInteger>
SignedInteger i_scan(const SignedInteger lower, const SignedInteger upper,
                     const int end) {
  using int_type = SignedInteger;
  int_type ret = 0;
  bool negative_flag = false;
  int c = c_scan();
  if (c == '-') {
    negative_flag = true;
    c = c_scan();
  }
  if (c < '0' || '9' < c) {
    std::cerr << "no digits" << std::endl;
    std::abort();
  }
  while ('0' <= c && c <= '9') {
    c -= '0';
    if (ret > (std::numeric_limits<int_type>::max() - c) / 10) {
      std::cerr << "overflow" << std::endl;
      std::abort();
    }
    ret = ret * 10 + c;
    c = c_scan();
  };
  if (c != end) {
    std::cerr << "expected " << c_to_str(end) << ", found " << c_to_str(c)
              << std::endl;
    std::abort();
  }
  if (negative_flag) {
    ret = -ret;
  }
  if (ret < lower || upper < ret) {
    std::cerr << "range was [" << lower << ", " << upper << "], found " << ret
              << std::endl;
    std::abort();
  }
  return ret;
}

void check() {
  int n = i_scan(1, 300000, '\n');
  for (int i = 0; i != n - 1; ++i) {
    i_scan(1, 300000, ' ');
  }
  i_scan(1, 300000, '\n');
  assert(c_scan() == std::char_traits<char>::eof());
}

} // namespace checker

int main() { checker::check(); }
0