結果
| 問題 |
No.1747 Many Formulae 2
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2023-11-18 05:28:48 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 742 bytes |
| コンパイル時間 | 971 ms |
| コンパイル使用メモリ | 104,848 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-26 05:40:27 |
| 合計ジャッジ時間 | 1,815 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<cassert>
#include<set>
#include<queue>
using namespace std;
using ll = long long;
string s;
int ans;
void dfs(ll now,ll tmp,int ni){
int n = s.size();
if(ni==n){
now += tmp;
bool fn = false;
if(now==1) fn = true;
for(ll i = 2;i*i<=now;i++){
if(now%i==0)fn = true;
}
if(!fn) ans++;
return;
}
if(ni!=0){
ll nxt = now + tmp;
ll t = s[ni] - '0';
dfs(nxt,t,ni+1);
}
tmp *= 10;
tmp += s[ni] -'0';
dfs(now,tmp,ni+1);
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin>>s;
dfs(0,0,0);
cout<<ans<<endl;
}
momoyuu