結果
| 問題 |
No.1747 Many Formulae 2
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2021-11-19 21:34:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 2,000 ms |
| コード長 | 1,006 bytes |
| コンパイル時間 | 1,662 ms |
| コンパイル使用メモリ | 172,600 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 21:46:37 |
| 合計ジャッジ時間 | 2,833 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
int main(){
int MAX_N = 100100;
vector<bool> PNJudge(MAX_N,true);
vector<ll> pn;
PNJudge[1] = false;
for(int i=2;i<MAX_N;i++){
if(!PNJudge[i]) continue;
pn.push_back(i);
for(int j=i*2;j<MAX_N;j+=i) PNJudge[j] = false;
}
string s;
cin >> s;
if(s=="1"){
cout << 0 << endl;
return 0;
}
int n = s.size(), ans = 0;
rep(i,1<<(n-1)){
int ic = i, be = 0;
ll x = 0;
rep(j,n-1){
if(ic&1){
x += stol(s.substr(be,j+1-be));
be = j+1;
}
ic >>= 1;
}
x += stol(s.substr(be,n-be));
bool ok = true;
for(ll p:pn){
if(!(x%p) && x/p != 1) ok = false;
}
ans += ok;
}
cout << ans << endl;
return 0;
}
houren