結果
問題 |
No.1862 Copy and Paste
|
ユーザー |
![]() |
提出日時 | 2024-11-26 14:52:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,935 bytes |
コンパイル時間 | 2,881 ms |
コンパイル使用メモリ | 214,164 KB |
最終ジャッジ日時 | 2025-02-25 06:15:11 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 24 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:20: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | freopen(file_name ".in", "r", stdin), freopen(file_name ".out", "w", stdout); \ | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:47:5: note: in expansion of macro ‘csf’ 47 | csf; | ^~~ main.cpp:9:58: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | freopen(file_name ".in", "r", stdin), freopen(file_name ".out", "w", stdout); \ | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:47:5: note: in expansion of macro ‘csf’ 47 | csf; | ^~~ main.cpp:67:46: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized] 67 | ::ans = min(::ans, (__)a * i + (__)b * ans); | ~~~~~~^~~~~ main.cpp:54:31: note: ‘ans’ was declared here 54 | ll l = i, r = n, mid, ans; | ^~~
ソースコード
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #ifndef LOCAL #define file_name "" #define csf \ { \ std::cerr.setstate(std::ios_base::failbit); \ if (file_name != "") \ freopen(file_name ".in", "r", stdin), freopen(file_name ".out", "w", stdout); \ } #define db(x) #else #define db(x) cerr << __FUNCTION__ << " L" << __LINE__ << " " << #x " = " << (x) << endl #define csf #endif #define ll long long #define unordered_map __gnu_pbds::gp_hash_table #define f(x, y, z) for (ll x = (y); x <= (z); x++) inline ll read(); using namespace std; using __ = __int128; const long long INF = 0x3f3f3f3f3f3f3f3f, M = 65; ll n, a, b; __ ans = INF; bool check(ll x, ll y) { //????? ll a = y / x, b = y % x; __ res = 1; f(i, 1, x - b) { res *= a + 1; if (res > 1e18) return 1; } f(i, 1, b) { res *= a + 2; if (res > 1e18) return 1; } return res >= n; } signed main() { csf; cin>>a>>b>>n; n++; f(i, 1, 65) { //????? ll l = i, r = n, mid, ans; while (l <= r) { mid = (l + r) / 2; if (check(i, mid)) { ans = mid; r = mid - 1; } else l = mid + 1; } ::ans = min(::ans, (__)a * i + (__)b * ans); } cout << (ll)ans << endl; return 0; } /* ????????? ?????? ????? 1 ????????? 3 ????23?????? ????????????????w????v????????????v/w????? ???k??? ???? x + k * y???? k + 1 x = 3, y = 1 k = 3 4 / 6 6 / 8 --------------- ??????? ??????? ?????? ??????????? */