Submission #17449864


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things. 
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

int main(){
	
	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll x,y,a,b;
    cin>>x>>y>>a>>b;

    ll ans=0;
    while(x<y){
    	// cerr<<x<<" "<<y<<" "<<a<<" "<<b<<endl;
    	if(LLONG_MAX/x >= a &&  x*a-x <= b){
    		x*=a;
    		ans++;
    	}
    	else{
    		ans+=(y-x)/b;
    		if((y-x)%b!=0)ans++;
    		break;
    	}
    }

    cout<<ans-1<<endl;

}

Submission Info

Submission Time
Task D - Takahashi Unevolved
User geckods
Language C++ (GCC 9.2.1)
Score 400
Code Size 1109 Byte
Status AC
Exec Time 8 ms
Memory 3644 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, max_01.txt, max_02.txt, max_03.txt, max_04.txt, max_05.txt, max_06.txt, max_07.txt, max_08.txt, max_09.txt, max_10.txt, max_11.txt, max_12.txt, max_13.txt, max_14.txt, max_15.txt, max_16.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 8 ms 3520 KB
max_01.txt AC 2 ms 3480 KB
max_02.txt AC 3 ms 3596 KB
max_03.txt AC 3 ms 3532 KB
max_04.txt AC 2 ms 3600 KB
max_05.txt AC 2 ms 3476 KB
max_06.txt AC 4 ms 3596 KB
max_07.txt AC 2 ms 3532 KB
max_08.txt AC 2 ms 3468 KB
max_09.txt AC 2 ms 3596 KB
max_10.txt AC 3 ms 3532 KB
max_11.txt AC 2 ms 3520 KB
max_12.txt AC 2 ms 3588 KB
max_13.txt AC 3 ms 3596 KB
max_14.txt AC 2 ms 3512 KB
max_15.txt AC 3 ms 3596 KB
max_16.txt AC 3 ms 3576 KB
random_01.txt AC 3 ms 3576 KB
random_02.txt AC 2 ms 3464 KB
random_03.txt AC 3 ms 3640 KB
random_04.txt AC 2 ms 3520 KB
random_05.txt AC 2 ms 3556 KB
random_06.txt AC 3 ms 3644 KB
random_07.txt AC 2 ms 3520 KB
random_08.txt AC 2 ms 3560 KB
random_09.txt AC 2 ms 3628 KB
random_10.txt AC 2 ms 3572 KB
random_11.txt AC 4 ms 3480 KB
random_12.txt AC 3 ms 3592 KB
sample_01.txt AC 2 ms 3468 KB
sample_02.txt AC 2 ms 3532 KB