結果
| 問題 | 
                            No.1747 Many Formulae 2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             SSRS
                         | 
                    
| 提出日時 | 2021-11-19 21:21:30 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 594 bytes | 
| コンパイル時間 | 1,694 ms | 
| コンパイル使用メモリ | 168,408 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-31 20:39:39 | 
| 合計ジャッジ時間 | 2,595 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 18 WA * 1 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  for (int i = 0; i < (1 << (N - 1)); i++){
    int x = S[0] - '0';
    int sum = 0;
    for (int j = 0; j < N - 1; j++){
      if ((i >> j & 1) == 1){
        sum += x;
        x = 0;
      }
      x = x * 10 + (S[j + 1] - '0');
    }
    sum += x;
    if (sum > 1){
      bool ok = true;
      for (long long j = 2; j * j <= sum; j++){
        if (sum % j == 0){
          ok = false;
        }
      }
      if (ok){
        ans++;
      }
    }
  }
  cout << ans << endl;
}
            
            
            
        
            
SSRS