#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl "\n"
#define ll long long
#define str string
#define dl double
#define ts(val) to_string(val)
#define ti(val) stoi(val)
#define ft first
#define sc second
#define Pb push_back
#define pB pop_back
#define mp make_pair
#define mst(array,value) memset(array,value,sizeof(array))
#define gtr greater<int>()
#define all(ar) ar.begin(),ar.end()
using namespace std;
#define ull unsigned long long int
//#define int long long
ull sum[] = {9,1,2,3,4,5,6,7,8};
signed main() {
//fast
//cout << (ll)pow(2,60);
//1152921504606846976
int t; cin >> t;
while(t--) {
ull a,b; cin >> a >> b;
ull x = a%9, y = b%9;
//cout << x << " " << y << nl;
ull z = (b-a)/9;
//cout << z << nl;
ull ans = z*45;
//cout << ans << nl;
if(x > y) {
for(int i=x;i<=8;i++) ans += sum[i];
for(int i=0;i<=y;i++) ans += sum[i];
} else {
for(int i=x;i<=y;i++) ans += sum[i];
}
cout << ans << nl;
}
return 0;
}
Compilation message
trol.cpp: In function 'int main()':
trol.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
41 | for(int i=0;i<=y;i++) ans += sum[i];
| ~^~~
trol.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
43 | for(int i=x;i<=y;i++) ans += sum[i];
| ~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |