結果

問題 No.1747 Many Formulae 2
ユーザー naskyanaskya
提出日時 2021-11-20 02:42:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 69,600 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 16:17:07
合計ジャッジ時間 1,940 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

int main() {
  std::string S;
  std::cin >> S;

  const int N = static_cast<int>(std::size(S));
  int res     = 0;

  for (int mask = 0; mask < (1 << (N - 1)); ++mask) {
    long long value = 0, tmp = 0;

    for (int i = 0; i < N; ++i) {
      tmp = tmp * 10 + (S[i] - '0');
      if (((mask >> i) & 1) == 1) {
        value += tmp;
        tmp = 0;
      }
    }

    value += tmp;

    res += [&] {
      for (int p = 2; p <= value / p; ++p) {
        if (value % p == 0) {
          return false;
        }
      }
      return true;
    }();
  }

  std::cout << res << '\n';
}
0