#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pb push_back
#define endl '\n'
#define rep(x) cout << #x << "= " << x << endl
#define OK cout << "OK\n"
using namespace std;
const int MOD = 1e9 + 7;
const int N = 510;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T;
cin >> T;
while(T--) {
int a, b;
cin >> a >> b;
int ans = 0;
if ( a + (9 - a % 9) + 1 <= b) {
ans += 45 - (9 - a % 9) * (10 - a % 9) / 2;
rep(ans);
OK;
a += (9 - a % 9) + 1;
}
for (int i = a + 9; i <= b; i += 9) {
ans += 45;
OK;
a = i;
}
for (int i = a; i <= b; ++i)
ans += (i % 9 ? i % 9 : 9) ;
cout << ans << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Execution timed out |
1076 ms |
121548 KB |
Time limit exceeded |
5 |
Execution timed out |
1088 ms |
121336 KB |
Time limit exceeded |