結果
問題 |
No.2207 pCr検査
|
ユーザー |
|
提出日時 | 2023-02-09 18:32:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 937 bytes |
コンパイル時間 | 1,730 ms |
コンパイル使用メモリ | 171,824 KB |
実行使用メモリ | 84,232 KB |
最終ジャッジ日時 | 2024-07-06 20:21:17 |
合計ジャッジ時間 | 21,480 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn=1e7+5; int cnt[maxn];bool used[maxn];vector<int> pr; int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); for(int i=2;i<maxn;++i) {if(!used[i]) {pr.push_back(i);for(int j=i;j<maxn;j+=i) {used[j]=true;}}} int n;cin>>n; pair<int,int> a[n];int p=1; for(int i=0;i<n;++i) {cin>>a[i].first>>a[i].second;cnt[a[i].first]=a[i].second;p=max(p,a[i].first);} for(int i=1;i<=p-1;++i) { bool ok=true; for(int p1:pr) { if(p1>p) break; int ans=0; for(int j=p1;j<=p;j*=p1) { ans+=(p/j)-(i/j)-((p-i)/j); } ok&=(ans==cnt[p1]); if(!ok) break; } if(ok) { cout<<p<<' '<<i<<endl; return 0; } } cout<<(-1)<<' '<<(-1)<<endl; return 0; }