1
1 999999999999999679
1 Like
Thanks! Can you explain why r = floor((1.0 * r) / 3) * 3; this is giving wrong result?
Floating point arithmetic is inaccurate.
1 Like
Found this simple
//This code is given by- kiran_abc02
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define endl ā\nā
#define vec vector
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll c;
cin>>c;
while(cā){
ll a,b;
cin>>a>>b;
ll n=(b-a)/3;
if(a%3==2 && b%3==1){
cout<<n+1<<endl;
}
else if(a%3==0 || b%3==0){
cout<<n+1<<endl;
}
else{
cout<<n<<endl;
}
}
return 0;
}