1 条题解

  • 0
    @ 2025-4-12 21:41:03

    C :

    #include <stdio.h>
    
    long long int countLuckyNumber(long long int);
    
    int main()
    {
    	long long int A, B, countAMinus1, countB;
    	int T;
    	
    	while (EOF != scanf("%d", &T)){
    		
    		while (T--){
    			scanf("%lld%lld", &A, &B);
    			countB = countLuckyNumber(B);
    			countAMinus1 = countLuckyNumber(A-1);
    			printf("%lld\n", countB - countAMinus1);
    		}
    	}
    	
    	return 0;
    }
    
    long long int countLuckyNumber(long long int N)
    {
    	long long int countN, tmp;
    	int sum, unitsN;
    	
    	if (N < 0){
    		return 0;
    	}
    	
    	countN = N / 10;
    	tmp = countN;
    	unitsN = N % 10;
    
    	sum = 0;
    	while (tmp){
    		sum += tmp % 10;
    		tmp /= 10;
    	}
    	
    	sum %= 10;
    	if (sum == 0){
    		countN++;
    	}else if(sum + unitsN >= 10){
    		countN++;
    	}
    	
    	return countN;
    }
    
    • 1

    信息

    ID
    1152
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者