#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
int get_jarisoo(int x){
if(x == 0) return 1;
int ans = 0;
while(x){
ans++;
x /= 10;
}
return ans;
}
lint pw[18];
int main(){
pw[0] = 1;
for(int i=1; i<18; i++) pw[i] = pw[i-1] * 10;
int q;
cin >> q;
while(q--){
int a, b;
cin >> a >> b;
int z = get_jarisoo(a);
bool ok = 0;
for(int i=0; i<16; i++){
if(a + pw[z + i] > b){
printf("%d\n", i);
ok = 1;
break;
}
}
if(!ok) puts("16");
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
211 ms |
1528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
211 ms |
1528 KB |
Output is correct |
2 |
Correct |
233 ms |
2576 KB |
Output is correct |
3 |
Correct |
231 ms |
3692 KB |
Output is correct |
4 |
Correct |
238 ms |
4728 KB |
Output is correct |
5 |
Correct |
256 ms |
5728 KB |
Output is correct |
6 |
Correct |
221 ms |
6952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
211 ms |
1528 KB |
Output is correct |
2 |
Correct |
233 ms |
2576 KB |
Output is correct |
3 |
Correct |
231 ms |
3692 KB |
Output is correct |
4 |
Correct |
238 ms |
4728 KB |
Output is correct |
5 |
Correct |
256 ms |
5728 KB |
Output is correct |
6 |
Correct |
221 ms |
6952 KB |
Output is correct |
7 |
Correct |
257 ms |
8384 KB |
Output is correct |
8 |
Correct |
263 ms |
9824 KB |
Output is correct |
9 |
Correct |
245 ms |
11252 KB |
Output is correct |
10 |
Correct |
270 ms |
12740 KB |
Output is correct |
11 |
Correct |
291 ms |
14096 KB |
Output is correct |