結果

問題 No.2207 pCr検査
ユーザー maksimmaksim
提出日時 2023-02-09 18:32:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 937 bytes
コンパイル時間 2,595 ms
コンパイル使用メモリ 167,280 KB
実行使用メモリ 87,576 KB
最終ジャッジ日時 2023-09-21 01:36:44
合計ジャッジ時間 23,671 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
23,096 KB
testcase_01 AC 142 ms
21,860 KB
testcase_02 AC 1,483 ms
75,396 KB
testcase_03 AC 1,188 ms
58,848 KB
testcase_04 AC 1,003 ms
59,996 KB
testcase_05 AC 2,579 ms
87,576 KB
testcase_06 AC 418 ms
51,248 KB
testcase_07 AC 665 ms
49,800 KB
testcase_08 AC 674 ms
41,524 KB
testcase_09 AC 1,794 ms
72,888 KB
testcase_10 AC 153 ms
37,428 KB
testcase_11 AC 1,608 ms
71,232 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0