結果

問題 No.2207 pCr検査
ユーザー 沙耶花
提出日時 2023-02-03 21:46:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,523 ms / 3,000 ms
コード長 981 bytes
コンパイル時間 4,088 ms
コンパイル使用メモリ 251,144 KB
最終ジャッジ日時 2025-02-10 09:02:50
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001

constexpr int M = 10000001;
int main(){
	
	vector<int> mp(M,-1);
	for(int i=2;i<M;i++){
		if(mp[i]!=-1)continue;
		for(int j=i;j<M;j+=i)mp[j] = i;
	}
	vector<int> goal(M,0),cur(M,0);
	int ok = M;
	int m = 0;
	{
		int k;
		cin>>k;
		rep(i,k){
			int p,e;
			cin>>p>>e;
			goal[p] = e;
			ok--;
			m = max(m,p);
		}
	}
	
	rep(i,m/2){
		{
			int c = m-i;
			while(c!=1){
				int p = mp[c];
				if(cur[p]==goal[p])ok--;
				cur[p]++;
				if(cur[p]==goal[p])ok++;
				c /= p;
			}
		}
		{
			int c = i+1;
			while(c!=1){
				int p = mp[c];
				if(cur[p]==goal[p])ok--;
				cur[p]--;
				if(cur[p]==goal[p])ok++;
				c /= p;
			}
		}	
		if(ok==M){
			cout<<m<<' '<<i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<' '<<-1<<endl;
	
	return 0;
}
0