Can anyone tell me what's wrong with my approach for this problem

Revision en4, by idonthatephy, 2022-04-19 06:02:36

1578E - Easy Scheduling--this is the problem

here is my code. basically wont the total time be-- for i =0 to h-1 summation of ceil(2^i/p) is this observation wrong? For some reason the link is'nt working , so here is the code-

#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
 
using namespace std;
 
int main(){
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int t;
cin>>t;
while(t--){
    double h,p;
    cin>>h>>p;
    ll pow=1;
    ll time=0;
    
    for(int i=0;i<h;i++){
       
        time+=ceil(pow/p);
        
        pow*=2;
        
    }
    cout<<time<<endl;
}
return 0;
}
Tags help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English idonthatephy 2022-04-19 06:02:36 40
en3 English idonthatephy 2022-04-19 06:01:30 482
en2 English idonthatephy 2022-04-18 23:46:48 29
en1 English idonthatephy 2022-04-18 23:45:42 282 Initial revision (published)