Submission #17456658


Source Code Expand

Copy
/*  CREATED BY
    STREAM_CIPHER
    17-oct-2020
*/
#include<bits/stdc++.h>
using namespace std;
void __print(long long x) {cerr << x;}void __print(unsigned long long x) {cerr << x;}void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long int
#define double long double
#define fix_precision(n) cout<<fixed<<setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;//5*64M bit ->5*8M byte ->40MB size for long long int (64 bit)
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        double x,y,a,b;
        cin>>x>>y>>a>>b;
        bool saturated=false;
        double ans=0;
        while(x*a<x+b)
        {
        	x*=a;
        	if(x>=y)
        	{
        		saturated=1;
        		// x/=a;
        		break;
        	}
        	ans++;
        }
        debug(x,saturated,ans);
        if(!saturated) 
        {
        	int diff=(int)(y-x);
        	debug(diff);
        	int bb=b;
        	if(diff%bb!=0)
        		ans+=((diff)/bb);
        	else
        		ans+=(diff-1)/bb;
        }
        cout<<(int)ans<<endl;
}

Submission Info

Submission Time
Task D - Takahashi Unevolved
User Stream_Cipher
Language C++ (GCC 9.2.1)
Score 400
Code Size 2104 Byte
Status AC
Exec Time 6 ms
Memory 3748 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 6 ms 3652 KB
max_01.txt AC 2 ms 3728 KB
max_02.txt AC 3 ms 3692 KB
max_03.txt AC 4 ms 3668 KB
max_04.txt AC 3 ms 3732 KB
max_05.txt AC 4 ms 3668 KB
max_06.txt AC 3 ms 3664 KB
max_07.txt AC 3 ms 3656 KB
max_08.txt AC 3 ms 3648 KB
max_09.txt AC 3 ms 3648 KB
max_10.txt AC 2 ms 3696 KB
max_11.txt AC 2 ms 3652 KB
max_12.txt AC 3 ms 3676 KB
max_13.txt AC 3 ms 3720 KB
max_14.txt AC 3 ms 3736 KB
max_15.txt AC 2 ms 3660 KB
max_16.txt AC 2 ms 3728 KB
random_01.txt AC 2 ms 3708 KB
random_02.txt AC 3 ms 3652 KB
random_03.txt AC 2 ms 3672 KB
random_04.txt AC 2 ms 3644 KB
random_05.txt AC 2 ms 3652 KB
random_06.txt AC 3 ms 3660 KB
random_07.txt AC 2 ms 3668 KB
random_08.txt AC 3 ms 3656 KB
random_09.txt AC 3 ms 3748 KB
random_10.txt AC 3 ms 3648 KB
random_11.txt AC 3 ms 3656 KB
random_12.txt AC 2 ms 3664 KB
sample_01.txt AC 2 ms 3704 KB
sample_02.txt AC 4 ms 3660 KB