結果
| 問題 |
No.1955 Not Prime
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-05-20 23:16:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 2,000 ms |
| コード長 | 897 bytes |
| コンパイル時間 | 4,462 ms |
| コンパイル使用メモリ | 257,172 KB |
| 最終ジャッジ日時 | 2025-01-29 11:40:37 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
vector<bool> f(1000000,true);
bool check(int a,int b){
string s = to_string(a);
s += to_string(b);
return f[stoi(s)];
}
int main() {
int n;
cin>>n;
vector<int> a(n),b(n);
rep(i,n){
cin>>a[i]>>b[i];
}
f[1] = false;
for(int i=2;i<f.size();i++){
if(!f[i])continue;
for(int j=i*2;j<f.size();j+=i)f[j] = false;
}
two_sat S(n);
rep(i,n){
rep(j,n){
if(check(a[i],b[j])){
S.add_clause(i,1,j,1);
}
if(check(b[i],a[j])){
S.add_clause(i,0,j,0);
}
if(check(a[i],a[j])){
S.add_clause(i,1,j,0);
}
if(check(b[i],b[j])){
S.add_clause(i,0,j,1);
}
}
}
if(S.satisfiable())cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
沙耶花