[SWEA] 4530 극한의 청소 작업

Time Lapse :58min 11sec

4530.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
long long A, B;
long long f(long long A){
long long ret = 0;
long long pow = 1;
while(A){
ret += (A%10)>4 ? ((A%10)-1)*pow : (A%10)*pow;
A *= 0.1;
pow *= 9;
}
return ret;
}
int main(void) {
int T, tc = 0;
scanf("%d",&T);
while(T--){
scanf("%llu %llu",&A,&B);
printf("#%d %llu\n",++tc,B<0 ? f(-A) - f(-B) : A<0 ? f(-A) + f(B) - 1 : f(B) - f(A));
}
return 0;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/4530/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.