結果
| 問題 |
No.1747 Many Formulae 2
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-04-17 00:44:40 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 746 bytes |
| コンパイル時間 | 3,233 ms |
| コンパイル使用メモリ | 275,048 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-17 00:44:45 |
| 合計ジャッジ時間 | 4,311 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
inline bool is_prime(ll n) {
if (n < 2) return false;
for (ll i = 2; i * i <= n; ++i) {
if (n % i == 0) return false;
}
return true;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
string s;
cin >> s;
int ans = 0;
rep(bit, 1 << (s.size() - 1)) {
ll sum = 0;
ll num = 0;
rep(i, s.size()) {
num = num * 10 + (s[i] - '0');
if (bit & (1 << i)) sum += num, num = 0;
}
sum += num;
if (is_prime(sum)) ++ans;
}
cout << ans << '\n';
return 0;
}
a01sa01to