結果

問題 No.1747 Many Formulae 2
ユーザー inksamuraiinksamurai
提出日時 2021-11-19 21:25:36
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 4,010 ms
コンパイル使用メモリ 130,508 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 07:17:39
合計ジャッジ時間 5,273 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0