結果
問題 | No.1862 Copy and Paste |
ユーザー |
![]() |
提出日時 | 2024-11-13 21:59:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,214 bytes |
コンパイル時間 | 709 ms |
コンパイル使用メモリ | 81,552 KB |
最終ジャッジ日時 | 2025-02-25 04:06:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 26 WA * 1 |
ソースコード
#include<iostream>#include<cmath>#include<cstdio>#include<cassert>#define int __int128using namespace std;int qpow(int x,int y){if(y == 0) return 1;int k = qpow(x,y / 2);if(y & 1) return k * k * x;else return k * k;}inline int read(){int x = 0, f = 1;char ch = getchar();while(!isdigit(ch)){if(ch == '-') f = -1;ch = getchar();}while(isdigit(ch)){x = (x << 3) + (x << 1) + (ch ^ 48);ch = getchar();}return x * f;}void write(__int128 x){if(x < 10) putchar('0' + x);else write(x / 10), putchar('0' + x % 10);}signed main(){long long n,x,y;__int128 ans = 9e18 + 1 + 1;// n = read(); x = read(); y = read();cin >> x >> y >> n;int up = log(n) / log(2) + 1;// cout << up << endl;for(int i = 1; i <= up; i++){// assert(pow(n,1.0 / i)>=0);int u = floor(pow(n,1.0 / i)) + 1, cnt = 0;__int128 xm = 1;for(int j = 1; j <= i; j++) xm *= u;// assert(xm>=0);while(xm >= n){xm /= u;xm *= (u - 1);cnt++;}xm /= (u - 1);xm *= u;// assert(xm>=0);cnt--;ans = min(ans, (__int128)i * x + (__int128)cnt * (u - 2) * y + (__int128)(i - cnt) * (u - 1) * y);// assert(ans>=0);}write(ans);cout << endl;return 0;}