結果

問題 No.2207 pCr検査
ユーザー 👑 tatyamtatyam
提出日時 2022-07-13 01:35:00
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 498 ms / 3,000 ms
コード長 927 bytes
コンパイル時間 3,315 ms
コンパイル使用メモリ 246,012 KB
実行使用メモリ 8,196 KB
最終ジャッジ日時 2023-09-15 16:09:27
合計ジャッジ時間 14,268 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 396 ms
5,392 KB
testcase_03 AC 232 ms
5,080 KB
testcase_04 AC 293 ms
4,868 KB
testcase_05 AC 396 ms
6,200 KB
testcase_06 AC 321 ms
4,380 KB
testcase_07 AC 216 ms
4,376 KB
testcase_08 AC 128 ms
4,380 KB
testcase_09 AC 308 ms
5,480 KB
testcase_10 AC 188 ms
4,380 KB
testcase_11 AC 297 ms
5,296 KB
testcase_12 AC 341 ms
5,752 KB
testcase_13 AC 205 ms
4,552 KB
testcase_14 AC 52 ms
4,376 KB
testcase_15 AC 370 ms
4,960 KB
testcase_16 AC 184 ms
4,692 KB
testcase_17 AC 302 ms
4,892 KB
testcase_18 AC 225 ms
4,380 KB
testcase_19 AC 125 ms
4,376 KB
testcase_20 AC 176 ms
4,376 KB
testcase_21 AC 411 ms
6,180 KB
testcase_22 AC 498 ms
8,188 KB
testcase_23 AC 497 ms
8,196 KB
testcase_24 AC 62 ms
4,376 KB
testcase_25 AC 177 ms
4,380 KB
testcase_26 AC 154 ms
4,380 KB
testcase_27 AC 292 ms
4,504 KB
testcase_28 AC 438 ms
6,884 KB
testcase_29 AC 438 ms
6,592 KB
testcase_30 AC 438 ms
6,552 KB
testcase_31 AC 437 ms
6,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:36:32: 警告: ‘R’ may be used uninitialized [-Wmaybe-uninitialized]
   36 |         if(e != f(P) - f(R) - f(P - R)){
      |                               ~^~~~~~~
main.cpp:19:9: 備考: ‘R’ はここで定義されています
   19 |     int R;
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ld = long double;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    vector<pair<int, int>> N(k);
    ld lgN = 0;
    for(auto& [p, e] : N){
        cin >> p >> e;
        lgN += logl(p) * e;
    }
    const int P = N.back().first;
    ld lg = 0, err = INFINITY;
    int R;
    for(int i = 0; i < P / 2; i++){
        lg += logl(P - i) - logl(i + 1);
        if(err > abs(lgN - lg)){
            err = abs(lgN - lg);
            R = i + 1;
        }
    }
    for(auto [p, e] : N){
        auto f = [p = p](int x){
            int ans = 0;
            while(1){
                x /= p;
                if(x == 0) return ans;
                ans += x;
            }
        };
        if(e != f(P) - f(R) - f(P - R)){
            cout << "-1 -1" << endl;
            return 0;
        }
    }
    cout << P << ' ' << R << endl;
}
0