結果
問題 | No.2244 Integer Complete |
ユーザー | kotatsugame |
提出日時 | 2023-03-10 22:34:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 618 bytes |
コンパイル時間 | 627 ms |
コンパイル使用メモリ | 69,444 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-18 04:44:33 |
合計ジャッジ時間 | 2,770 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 60 |
ソースコード
#include<iostream> #include<cmath> using namespace std; int N,M; bool A[30303],B[30303]; int mysq(int N) { int n=sqrt(N); if((n+1)*(n+1)<=N)n++; return n; } int main() { cin>>N>>M; for(int i=0;i<N;i++) { int a;cin>>a; A[a]=true; } for(int i=0;i<M;i++) { int b;cin>>b; B[b]=true; } if(!A[1]||!B[1]) { cout<<1<<endl; return 0; } int k=1; while(A[k]||B[k])k++; for(int u=k*k;;u++) { bool fn=false; for(int t=2;t*t<=u;t++)if(u%t==0) { int a=mysq(t),b=mysq(u/t); if(A[a]&&B[b]||A[b]&&B[a]) { fn=true; break; } } if(!fn) { cout<<u<<endl; return 0; } } }