結果
問題 | No.2207 pCr検査 |
ユーザー | Ricky_pon |
提出日時 | 2023-02-04 19:12:11 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,134 ms / 3,000 ms |
コード長 | 4,665 bytes |
コンパイル時間 | 1,447 ms |
コンパイル使用メモリ | 138,240 KB |
実行使用メモリ | 86,900 KB |
最終ジャッジ日時 | 2023-09-16 15:42:49 |
合計ジャッジ時間 | 31,831 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,352 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 601 ms
73,772 KB |
testcase_03 | AC | 376 ms
46,388 KB |
testcase_04 | AC | 373 ms
53,928 KB |
testcase_05 | AC | 844 ms
76,712 KB |
testcase_06 | AC | 243 ms
61,548 KB |
testcase_07 | AC | 230 ms
44,244 KB |
testcase_08 | AC | 187 ms
26,008 KB |
testcase_09 | AC | 602 ms
59,580 KB |
testcase_10 | AC | 86 ms
37,084 KB |
testcase_11 | AC | 526 ms
56,968 KB |
testcase_12 | AC | 1,697 ms
71,044 KB |
testcase_13 | AC | 965 ms
43,728 KB |
testcase_14 | AC | 206 ms
14,340 KB |
testcase_15 | AC | 2,045 ms
82,180 KB |
testcase_16 | AC | 830 ms
39,800 KB |
testcase_17 | AC | 1,585 ms
65,176 KB |
testcase_18 | AC | 1,191 ms
52,588 KB |
testcase_19 | AC | 531 ms
27,648 KB |
testcase_20 | AC | 894 ms
41,212 KB |
testcase_21 | AC | 2,134 ms
83,596 KB |
testcase_22 | AC | 1,734 ms
86,900 KB |
testcase_23 | AC | 1,725 ms
85,628 KB |
testcase_24 | AC | 274 ms
18,652 KB |
testcase_25 | AC | 813 ms
36,872 KB |
testcase_26 | AC | 738 ms
35,844 KB |
testcase_27 | AC | 1,577 ms
65,956 KB |
testcase_28 | AC | 1,155 ms
84,568 KB |
testcase_29 | AC | 1,168 ms
84,004 KB |
testcase_30 | AC | 1,146 ms
85,128 KB |
testcase_31 | AC | 1,161 ms
85,028 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:207:19: 警告: ‘n’ may be used uninitialized [-Wmaybe-uninitialized] 207 | printf("%d %d\n", n, r + 1); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:174:9: 備考: ‘n’ はここで定義されています 174 | int n; | ^
ソースコード
// #include <bits/stdc++.h> #include <string.h> #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <ciso646> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define For(i, a, b) for (int i = (int)(a); (i) < (int)(b); ++(i)) #define rFor(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); --(i)) #define rep(i, n) For(i, 0, n) #define rrep(i, n) rFor(i, n, 0) #define fi first #define se second #include <algorithm> #include <bitset> #include <vector> namespace rklib { struct SimpleSieve { std::vector<bool> is_prime; std::vector<int> prime; SimpleSieve(int n) { is_prime.resize(n + 1, true); is_prime[0] = is_prime[1] = false; for (int i = 2; i <= n; ++i) { if (!is_prime[i]) continue; prime.push_back(i); for (int j = 2; i * j <= n; ++j) { is_prime[i * j] = false; } } } }; struct Sieve { std::vector<int> min_factor, prime; Sieve(int n) { min_factor.resize(n + 1, 0); for (int i = 2; i <= n; ++i) { if (min_factor[i] == 0) { min_factor[i] = i; prime.push_back(i); } for (int x : prime) { if (x * i > n || x > i) break; min_factor[x * i] = x; } } } std::vector<std::pair<int, int>> prime_factor(int n) { std::vector<std::pair<int, int>> res; while (n > 1) { if (res.empty() || res.rbegin()->first != min_factor[n]) { res.emplace_back(min_factor[n], 1); } else ++res.rbegin()->second; n /= min_factor[n]; } return res; } void divisor_dfs(std::vector<std::pair<int, int>> &p, int t, int cur, std::vector<int> &res) { if (cur == (int)p.size()) { res.push_back(t); return; } divisor_dfs(p, t, cur + 1, res); for (int _ = 0; _ < p[cur].second; ++_) { t *= p[cur].first; divisor_dfs(p, t, cur + 1, res); } } std::vector<int> get_divisor(int n, bool sorted = false) { std::vector<int> res; auto p = prime_factor(n); divisor_dfs(p, 1, 0, res); if (sorted) sort(res.begin(), res.end()); return res; } }; } // namespace rklib #include <algorithm> #include <cassert> #include <vector> namespace rklib { template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmin_non_negative(T &a, const T &b) { if (a < 0 || a > b) { a = b; return true; } return false; } template <class T> T div_floor(T a, T b) { if (b < 0) a *= -1, b *= -1; return a >= 0 ? a / b : (a + 1) / b - 1; } template <class T> T div_ceil(T a, T b) { if (b < 0) a *= -1, b *= -1; return a > 0 ? (a - 1) / b + 1 : a / b; } } // namespace rklib using namespace std; using namespace rklib; using lint = long long; using pii = pair<int, int>; using pll = pair<lint, lint>; int prime_factors[10'000'010]; int main() { int K; scanf("%d", &K); int n; rep(i, K) { int p, e; scanf("%d%d", &p, &e); prime_factors[p] += e; if (i == K - 1) n = p; } Sieve sv(n); int cnt_nonzero = K; rep(r, n) { { int tmp = n - r; while (tmp != 1) { int mf = sv.min_factor[tmp]; if (prime_factors[mf] == 0) ++cnt_nonzero; --prime_factors[mf]; if (prime_factors[mf] == 0) --cnt_nonzero; tmp /= mf; } } { int tmp = r + 1; while (tmp != 1) { int mf = sv.min_factor[tmp]; if (prime_factors[mf] == 0) ++cnt_nonzero; ++prime_factors[mf]; if (prime_factors[mf] == 0) --cnt_nonzero; tmp /= mf; } } if (cnt_nonzero == 0) { printf("%d %d\n", n, r + 1); return 0; } } printf("%d %d\n", -1, -1); }