結果

問題 No.358 も~っと!門松列
ユーザー koturn
提出日時 2016-04-24 18:00:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,069 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 69,632 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 00:03:16
合計ジャッジ時間 1,280 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <algorithm>
#include <array>
#include <iostream>

static constexpr int A_MAX = 1000;


int
main()
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  std::array<int, 3> as;
  std::cin >> as[0] >> as[1] >> as[2];
  if (as[0] == as[1] || as[1] == as[2] || as[2] == as[0]) {
    std::cout << 0 << std::endl;
    return EXIT_SUCCESS;
  }

  auto mm = std::minmax_element(as.begin(), as.end());
  if (as.begin() + 1 == mm.first || as.begin() + 1 == mm.second) {
    std::cout << "INF" << std::endl;
    return EXIT_SUCCESS;
  }

  int cnt = 0;
  std::array<int, 3> bs;
  for (int i = 1, iMax = *std::max_element(as.begin(), as.end()); i <= iMax; i++) {
    for (decltype(as)::size_type j = 0; j < as.size(); j++) {
      bs[j] = as[j] % i;
    }
    if (bs[0] == bs[1] || bs[1] == bs[2] || bs[2] == bs[0]) {
      continue;
    }
    auto mm = std::minmax_element(bs.begin(), bs.end());
    if (bs.begin() + 1 == mm.first || bs.begin() + 1 == mm.second) {
      cnt++;
    }
  }
  std::cout << cnt << std::endl;

  return EXIT_SUCCESS;
}
0