Submission

Status:
PPPP------

Score: 40

User: akuyga1

Problemset: J.Nine Khanaphat

Language: c

Time: 0.002 second

Submitted On: 2024-10-15 09:40:35

#include <stdio.h>
#include <math.h>

int count(int x){
    int temp=x;
    int count=0;
    int N=0;
    while(x!=0){
        if(x%10<9){count+=(x%10)*N*pow(10,N-1);x/=10;}
        else {
            count+=(9)*N*pow(10,N-1);
            count+=temp-(x*pow(10,N))+1;
            x/=10;
            
        }
        N++;
    }
    return count;
    
}

int main() {
    //for each 10^n you find that there is n*20^(n-1) each num
    int x,y;
    scanf("%d %d",&x,&y);
    printf("%d",count(y)-count(x-1));
    return 0;
    
}