結果
| 問題 | 
                            No.1747 Many Formulae 2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yukihira_pot
                         | 
                    
| 提出日時 | 2021-11-19 21:45:04 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,238 bytes | 
| コンパイル時間 | 1,989 ms | 
| コンパイル使用メモリ | 170,656 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-31 22:36:42 | 
| 合計ジャッジ時間 | 2,696 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int> >;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rep_ll(i, a, b) for(ll i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const int INFI = 1 << 29;
const ll INFL = 1LL << 59;
bool isprime(ll m) {
    ll tmp = m;
    if (tmp == 1) return false;
    for (ll i = 2; i * i <= m; i++) {
        if (tmp % i == 0) {
            return false;
        }
    }
    return true;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s; cin >> s;
    vector<ll> A;
    ll n = 0;
    while (s) {
        A.push_back(s % 10);
        s /= 10;
        n++;
    }
    reverse(all(A));
    int ans = 0;
    rep(bit, 0, 1 << (n-1)) {
        ll tmp = 0;
        ll check = 0;
        rep(i, 0, n) {
            tmp += A[i];
            if (bit & (1 << i)) {
                check += tmp;
                tmp = 0;
            }
            else if (i == n-1) check += tmp;
            else tmp *= 10;
        }
        if (isprime(check)) ans++;
    }
    cout << ans << endl;
}
            
            
            
        
            
yukihira_pot