結果

問題 No.1747 Many Formulae 2
ユーザー Nzt3
提出日時 2022-09-27 17:55:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 194,248 KB
最終ジャッジ日時 2025-02-07 17:21:44
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin>>S;
  int N=S.size()-1;
  int ans=0;
  for(int i=0;i<1<<N;i++){
    long long t=0,p=0;
    for(int j=0;j<N;j++){
      t=t*10+S[j]-'0';
      if(i>>j&1)p+=t,t=0;
    }
    t=t*10+S[N]-'0';
    p+=t;
    int a=1;
    if(p==1)a=0;
    for(int j=2;j*j<=p;j++){
      if(p%j==0){
        a=0;
        break;
      }
    }
    ans+=a;
  }
  cout<<ans<<'\n';
}
0