結果

問題 No.1862 Copy and Paste
ユーザー milanis48663220
提出日時 2022-03-04 23:19:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 2,564 bytes
コンパイル時間 1,331 ms
コンパイル使用メモリ 117,756 KB
最終ジャッジ日時 2025-01-28 06:27:38
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
using P = pair<int, int>;
vector<int> facs(int a){
vector<int> ans;
for(int x = 1; x*x <= a; x++){
if(a%x == 0){
ans.push_back(x);
}
if(x*x != a) ans.push_back(x);
}
sort(ans.begin(), ans.end());
return ans;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
ll a, b, n; cin >> a >> b >> n;
if(n == 1){
cout << 0 << endl;
return 0;
}
auto f = [&](ll x){
return a+b*(x-1);
};
auto judge = [&](ll a, int r){
ll x = 1;
for(int i = 0; i < r; i++){
x *= a;
if(x >= n) return true;
}
return false;
};
ll ans = 4e18;
for(int i = 1; i <= 30; i++){
ll l = 0, r = n+1;
while(r-l > 1){
ll a = (l+r)/2;
if(judge(a, i)) r = a;
else l = a;
}
ll tmp = 1;
ll score = 0;
for(int j = 0; j < i; j++){
int rem = i-j;
bool ok = false;
ll tt = tmp;
for(int k = 0; k < rem; k++){
tt *= r-1;
if(tt >= n) ok = true;
}
int x = r;
if(ok) x--;
tmp *= x;
score += f(x);
}
assert(tmp >= n);
chmin(ans, score);
}
cout << ans << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0