Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
599 B
0
Indexable
Never
#define ll long long
#define pb push_back
#define ipar(arr, n) vector<ll> arr(n); for(int i=0;i<n;i++) cin>>arr[i];
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
ll sod(ll n){
    ll res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

void solve(){
    ll l,r; cin>>l>>r;
    ll l1=l,r1=r;
    while(sod(l1)%3!=0) l1++;
    while(sod(r1)%3!=0) r1--;
    //cout<<l1<<" "<<r1<<"\n";
    ll res=(r1-l1)/3 +1;
    cout<<res<<"\n";
}


signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
	cin>>t;
	while(t--) solve();
}
Leave a Comment