Smail Set 一次 10分。
Large Set 兩次 0分。
// RecycledNumbers.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "string.h"
void main()
{
int line, len, i, n, k, x, A, B, m, head, tail, pow, pow2, ans, cnt, dup;
char str[8];
scanf("%d\n\r", &line);
for(i=0;i<line;i++) {
scanf("%d %d", &A, &B);
ans=0;
for(n=A;n<=B;n++)
{
//printf("%d => ", n);
sprintf(str,"%d",n);
len = strlen(str);
tail = n;
pow = 1;
pow2 = 1;
for(x = 0; x<len; x++) {
pow2 *= 10;
}
cnt = 0;
dup = 1;
if( len == 4 && (n%100 == n/100) ) {
dup=2;
}
if( len == 6 && (n%1000 == n/1000) ) {
dup=2;
}
if( len == 6 && (n%100 == (n/100)%100) && (n%100 == (n/10000))) {
dup=3;
}
for(k=1;k<len;k++) {
tail /= 10;
pow *= 10;
pow2 /= 10;
head = (n % pow)*pow2;
m = head + tail;
if( A<=n && n<m && m<=B ) {
//printf("%d ",m);
cnt++;
}
}
ans += cnt/dup;
//printf("\n");
}
printf("Case #%d: ", i+1);
printf("%d\n", ans);
}
}