結果
| 問題 |
No.1862 Copy and Paste
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-11-13 09:51:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 740 bytes |
| コンパイル時間 | 1,920 ms |
| コンパイル使用メモリ | 198,324 KB |
| 最終ジャッジ日時 | 2025-02-25 04:02:37 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%lld %lld %lld", &x, &y, &n);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e7+5;
ll n, x, y, ans=4e18;
int main() {
// freopen("dice.in", "r", stdin);
// freopen("dice.out","w",stdout);
scanf("%lld %lld %lld", &x, &y, &n);
if(n==1) {
puts("0");
return 0;
}
if((__int128)n*y<=(ll)(1e18))
ans=min(ans, x+(n-1)*y);
ll sq=sqrt(n), t=sq+sq-2;
if(sq*sq<n) t++;
if(sq*(sq+1)<n) t++;
if((__int128)t*y<=(ll)(1e18))
ans=min(ans, x+x+t*y);
for(ll i=3; i<=__lg(n)+1; i++) {
priority_queue<ll> q;
ll now=1, b=0;
for(int j=1; j<=i; j++) q.push(-2), now=now*2;
while(now<n) {
ll u=-q.top(); q.pop();
now/=u; now*=u+1;
q.push(-(u+1));
b++;
}
ans=min(ans, i*x+(i+b)*y);
}
printf("%lld\n", ans);
return 0;
}
vjudge1