CPP   72
unsigned long zero
Guest on 11th February 2023 01:29:41 AM

1. #include<stdio.h>
2. #include<math.h>
3. unsigned long zero(unsigned long numf,unsigned long numb,unsigned long ten,unsigned long num){
4.     unsigned long temp,an=0;
5.     if(numf<10){
6.      /*printf("%d %d %d %d\n",numf,numb,ten,num);
7.      printf("fnumb:%d\n",floor(numb/10)) ;*/
8.      if(floor(numb/(ten))==0)
9.             an=(numf-1)*ten+numb+1;
10.         else
11.             an=numf*ten;
12.
13.      /*printf("an:%d\n",an);*/
14.         return an;}
15.     else{
16.         /*printf("*-%d %d %d %d-*\n",numf,numb,ten,num);*/
17.         if(floor(numb/ten)==0)
18.             an=(numf-1)*ten+numb+1;
19.         else
20.             an=numf*ten;
21.         numb+=(numf%10)*ten*10;
22.         numf=(unsigned long)floor(num/(ten*100));
23.         /*printf("*-an:%d\n",an);*/
24.         return an+zero(numf,numb,ten*10,num);
25.     }
26.
27. }
28.
29.
30. int main(){
31.     unsigned long m,n;
32.     /*while(1) {
33.     scanf("%d",&n);
34.     printf("zero(n):%d",zero((unsigned long)floor(n/10),n%10,1,n)); }*/
35.     while(1){
36.         scanf("%d %d",&m,&n);
37.         /*m--;
38.         if(m==0)printf("%d\n",zero((unsigned long)floor(n/10),n%10,1,n)+1);
39.         else{printf("%d--\n",(unsigned long)floor(m/10));
40.         printf("%d\n",zero((unsigned long)floor(n/10),n%10,1,n)-zero((unsigned long)floor(m/10),m%10,1,m));
41.         }*/
42.         m--;
43.         printf("%d\n", zero(n/10, n%10, 1, n) - zero(m/10, m%10, 1, m));
44.     }
45.     return 0;
46. }

Raw Paste

or to edit or fork this paste. It's free.