标签:style io ar color os sp for on 数据
Acm队的流年对数学的研究不是很透彻,但是固执的他还是想一头扎进去。
浏览网页的流年忽然看到了网上有人用玫瑰花瓣拼成了521三个数字,顿时觉得好浪漫,因为每个男生都会不经意的成为浪漫的制造者。此后,流年走到哪里都能看到5、2、1三个数字,他怒了,现在他想知道在连续的数中有多少数全部包含了这三个数字。例如12356就算一个,而5111就不算。特别的,如果他看到了521三个数连续出现,会特别的愤怒。例如35210。
200 500 300 900 1 600
Case 1:2 0 Case 2:2 1 Case 3:6 1
#include<stdio.h>
struct data
{
int x,y;
}ss[1000000];
void f()
{
int n,m,i,t,p5,p0,p2,temp;
n=m=0;
for(i=1;i<1000000;++i)
{
temp=p0=p2=p5=0;
t=i;
while(t)
{
if(t%10==5)
p5=1;
else if(t%10==1)
p0=1;
else if(t%10==2)
p2=1;
if(p5&&p0&&p2)
{
temp=1;
m++;
break;
}
t/=10;
}
if(temp)
{
t=i;
while(t)
{
if(t%1000==521)
{
n++;
break;
}
t/=10;
}
}
ss[i].x+=m,ss[i].y+=n;
}
}
int main()
{
f();
int a,b,cs=0;
while(~scanf("%d%d",&a,&b))
{
printf("Case %d:%d %d\n",++cs,ss[b].x-ss[a-1].x,ss[b].y-ss[a-1].y);
}
return 0;
}标签:style io ar color os sp for on 数据
原文地址:http://blog.csdn.net/qq_18062811/article/details/41770301