Solution
#define ull unsigned long long
#include <stdio.h>
#include <stdbool.h>
bool ispal(int n){
int m=n,res=0;
while(n){
res*=10;
res+=n%10;
n/=10;
}
return res==m;
}
int main(){
int t;
scanf("%d",&t);
while(t--){
int i,min,max;
ull res=0;
scanf("%d%d",&min,&max);
for(i=min;i<=max;i++){
if(ispal(i)){
res+=i;
}
}
printf("sum is %lld\n",res);
}
return 0;
}
No comments:
Post a Comment