結果
| 問題 |
No.1747 Many Formulae 2
|
| コンテスト | |
| ユーザー |
nok0
|
| 提出日時 | 2021-11-10 23:55:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 499 bytes |
| コンパイル時間 | 2,108 ms |
| コンパイル使用メモリ | 193,184 KB |
| 最終ジャッジ日時 | 2025-01-25 15:16:00 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool is_prime(long long n) {
for(int i = 2; i <= sqrt(n); i++)
if(n % i == 0) return false;
return true;
}
int res;
int main() {
string s;
cin >> s;
for(int bit = 0; bit < 1 << (s.size() - 1); bit++) {
long long cur = s[0] - '0';
long long sum = 0;
for(int i = 0; i < s.size() - 1; i++) {
if(bit >> i & 1) sum += cur, cur = 0;
cur *= 10;
cur += s[i + 1] - '0';
}
sum += cur;
res += is_prime(sum);
}
cout << res << '\n';
}
nok0