QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#184889 | #5115. Clone Ranran | zwp1234 | AC ✓ | 39ms | 3648kb | C++17 | 2.6kb | 2023-09-21 14:00:40 | 2023-09-21 14:00:40 |
Judging History
answer
//# pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
#define SZ(x) (int)(x).size()
#define fs first
#define sc second
#define PII pair<int,int>
#define ls(u) (u)<<1
#define rs(u) (u)<<1|1
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vi >
#define vI vector<PII>
#define db double
#define all(a) (a).begin(),(a).end()
#define die cout << "???" << endl
//#define endl '\n'
using namespace std;
const int mod = 998244353;
//const int mod = 1169996969;
//const int mod = 1e9+7;
//const int inf = LLONG_MAX;
const int inf = 0x3f3f3f3f;
//const int inf = 1e9;
//const db PI = acos(-1.0);
const db eps = 1e-5;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+5,M = 3e5+5,K = 30;
inline int rd() {
int f = 0; int x = 0; char ch = getchar();
for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
if (f) x = -x;
return x;
}
void write(int a) {if(a>=10)write(a/10);putchar(a%10+'0');}
void wt(int a) {if(a < 0) {putchar('-');a = -a;}write(a);}
void wwt(int a){wt(a);putchar('\n');}
// void write(ll a) {if(a>=10)write(a/10);putchar(a%10+'0');}
// void wt(ll a) {if(a < 0) {putchar('-');a = -a;}write(a);}
// void wwt(ll a){wt(a);putchar('\n');}
int lowbit(int x) {return (x&(-x));}
int n,m,k;
int h[N],e[N],ne[N],tot;
void add(int u,int v)
{
e[tot] = v,ne[tot] = h[u],h[u] = tot++;
}
int f[N];
int out[N];
int dep[N];
void dfs(int u)
{
dep[u] = dep[f[u]] + 1;
for(int i = h[u];~i;i = ne[i])
{
int v = e[i];
dfs(v);
}
}
bool vis[N];
void dfs2(int u)
{
for(int i = h[u];~i;i = ne[i])
{
int v = e[i];
dep[v] = dep[u] + 1;
if(!vis[v])
dfs2(v);
}
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("in.txt", "r+", stdin);
freopen("out.txt", "w+", stdout);
#endif
int _;
for(cin >> _;_;_--)
{
cin >> n >> m >> k;
if(n <= m)
{
int t = 1,tmp = 0;
while(t < k)
{
t <<= 1;
tmp += n;
}
cout << tmp + m << endl;
}
else
{
int ans = m*k;
for(int i = 1,t = 0;i<=k;i <<= 1,t += n)
{
ans = min(ans,t + (k+i-1)/i*m);
}
cout << ans << endl;
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
5 1 1 1 2 3 3 9 9 9 3 26 47 1064 822 1048576
output:
1 7 45 44 21860
result:
ok 5 number(s): "1 7 45 44 21860"
Test #2:
score: 0
Accepted
time: 39ms
memory: 3648kb
input:
99500 1000000000 1000000000 1000000000 1000000000 1000000000 999999999 1000000000 1000000000 999999998 1000000000 1000000000 999999997 1000000000 1000000000 999999996 1000000000 1000000000 999999995 1000000000 1000000000 999999994 1000000000 1000000000 999999993 1000000000 1000000000 999999992 10000...
output:
31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999996 30999999996 30999999996 30999999996 30999999996 ...
result:
ok 99500 numbers