Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int t;
- cin>>t;
- while(t--){
- ll l,r,a,counter1=0,ans1=0,counter2=0,ans2=0,res=0,maxi=INT_MIN;
- cin>>l>>r>>a;
- for(ll i=l;i<=r;i++){
- if(counter1==0){
- if(i%a==0){
- ans1=i;
- counter1++;
- break;
- }else{
- continue;
- }
- }else if(counter1==1&&counter2==0){
- if(i%a==0){
- ans2=i;
- counter2++;
- break;
- }else{
- continue;
- }
- }else{
- continue;
- }
- }
- if(counter1==1||counter2==1){
- for(int i=ans1;i<=ans2;i++){
- res=(floor(i/a))+(i%a);
- maxi=max(res,maxi);
- }
- }cout<<maxi<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement