PROBLEM LINK:
Practice
Contest
Author: Tuấn Anh Trần Đặng
Tester: Kamil Dębowski
Editorialist: Tuấn Anh Trần Đặng
DIFFICULTY:
Cakewalk
PREREQUISITES:
Ad-hoc
Solution
In this problem we just need to “simulate” the activities of the Lazy Jem.
res = 0;
while (n) {
int problems = (n + 1) / 2;
res += problems * m;
n -= problems;
if (n) {
res += b;
}
m = m * 2;
}
Author’s/Tester’s Solutions:
Setter’s solution
Tester’s solution
The problem is not visible in Practice section. Please fix @admin @tuananh93
1 Like
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
int t;
cin>>t;
while(t–)
{
long long n,b,m;
cin>>n>>b>>m;
long long ans=0;
while(n>0)
{
if(n%2)
{
ans+=((n+1)/2)*m;
n-=(n+1)/2;
if(n>0)
ans+=b;
//cout<<“Ans=”<<ans<<" ";
}
else
{
ans+=(n/2)m;
n-=(n/2);
if(n>0)
ans+=b;
//cout<<“ans=”<<ans<<" ";
}
m=2;
}
cout<<endl;
cout<<ans<<endl;
}
return 0;
}