题解 | #数位五五#
数位五五
http://www.nowcoder.com/practice/4306996b0a534178b90b3514a8b30028
#include <stdio.h>
int fun(int a,int b){
int i,j,sum=0,count=0;
for(i=a;i<=b;i++){
j=i;
sum=0;
while(j!=0){
sum+=j%10;
j/=10;
}
if(sum%5==0) count++;
}
return count;
}
int main(){
long int a,b;
scanf("%ld%ld",&a,&b);
printf("%d",fun(a,b));
return 0;
}
int fun(int a,int b){
int i,j,sum=0,count=0;
for(i=a;i<=b;i++){
j=i;
sum=0;
while(j!=0){
sum+=j%10;
j/=10;
}
if(sum%5==0) count++;
}
return count;
}
int main(){
long int a,b;
scanf("%ld%ld",&a,&b);
printf("%d",fun(a,b));
return 0;
}