結果
| 問題 | 
                            No.1747 Many Formulae 2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             inksamurai
                         | 
                    
| 提出日時 | 2021-11-19 21:25:36 | 
| 言語 | C++17(clang)  (17.0.6 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 1,021 bytes | 
| コンパイル時間 | 2,808 ms | 
| コンパイル使用メモリ | 164,944 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-31 20:55:37 | 
| 合計ジャッジ時間 | 3,366 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3HaBFkZ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
 
ll toint(string s){
	ll x=1,c=0;
	for(int i=sz(s)-1;i>=0;i--){
		c+=(ll)(s[i]-'0')*x;
		x*=10;
	}
	return c;
}
int main(){
_3HaBFkZ;
	string s;
	cin>>s;
	int n=sz(s);
	int ans=0;
	rep(msk,1<<n){
		if(msk&(1<<(n-1))) continue;
		string now="";
		ll sum=0;
		rep(i,n){
			now+=s[i];
			if(msk&(1<<i)){
				sum+=toint(now);
				now="";
			}
		}
		if(sz(now)) sum+=toint(now);
		bool pok=1;
		for(int i=2;i<=sqrt(sum);i++){
			if(sum%i==0) pok=0;
		}
		// cout<<sum<<"\n";
		ans+=(pok and sum!=1);
	}
	cout<<ans<<"\n";
//	
	return 0;
}
            
            
            
        
            
inksamurai