关于521
时间限制:1000 ms | 内存限制:65535 KB 难度:2- 描述
-
Acm队的流年对数学的研究不是很透彻,但是固执的他还是想一头扎进去。
浏览网页的流年忽然看到了网上有人用玫瑰花瓣拼成了521三个数字,顿时觉得好浪漫,因为每个男生都会不经意的成为浪漫的制造者。此后,流年走到哪里都能看到5、2、1三个数字,他怒了,现在他想知道在连续的数中有多少数全部包含了这三个数字。例如12356就算一个,而5111就不算。特别的,如果他看到了521三个数连续出现,会特别的愤怒。例如35210。
- 输入
-
多组测试数据:
一行给定两个数a,b(0 输出 - 一行显示他想要知道的数有几个及显示有多少个数字令他特别的愤怒。用空格隔开。
- 样例输入
-
200 500 300 900 1 600
- 样例输出
-
Case 1:2 0 Case 2:2 1 Case 3:6 1
#includestruct 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; }
- <script type="text/java script">BAIDU_CLB_fillSlot("771048");
- 点击复制链接 与好友分享! 回本站首页 <script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)]; - 您对本文章有什么意见或着疑问吗?请到 论坛讨论您的关注和建议是我们前行的参考和动力??
- 相关文章
- <script type="text/java script">BAIDU_CLB_fillSlot("182716");
- <script type="text/java script">BAIDU_CLB_fillSlot("517916");
- 图文推荐
<iframe src="http://www.2cto.com/uapi.php?tid=358490&catid=339&title=bnlvai252NPaNTIx&forward=http://www.2cto.com/kf/201412/358490.html" width="100%" height="100%" id="comment_iframe" name="comment_iframe" frameborder="0" scrolling="no">
- <script type="text/java script">BAIDU_CLB_fillSlot("771057");



