Hua_Yueyan's blog

By Hua_Yueyan, history, 3 hours ago, In English

1860B i try many input,it is all right.please tell me the bug.

include<bits/stdc++.h>

using namespace std; long long m,k,a1,ak; long long bs(long long target,long long l,long long r){ long long mid=(l+r+1)/2; if(l>=r){ return l; } if(k*mid>target){ return bs(target,l,mid-1); } else{ return bs(target,mid,r); } } long long zero(){ if(m-k*bs(m,0,ak)<=a1){ return 0; } if(m-k*bs(m,0,ak)-a1>=k){ return bs(m-k*bs(m,0,ak)-a1,0,100000000)+m-k*bs(m,0,ak)-a1-k*bs(m-k*bs(m,0,ak)-a1,0,100000000); } if(k-(m-k*bs(m,0,ak)-a1)<=a1){ return 1; } return m-k*bs(m,0,ak)-a1; } int main(){ int t; cin>>t; for(int i=0;i<t;i++){ cin>>m>>k>>a1>>ak; cout<<zero()<<endl; } }

  • Vote: I like it
  • -6
  • Vote: I do not like it

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

read editorial bruh