Nanyang 975--about 521 (play table)

Source: Internet
Author: User

About 521 time limit:MS | Memory limit:65535 KB Difficulty:2
Describe

The ACM team's fleeting study of mathematics is not very thorough, but stubborn he still want to go in.

Browsing the Web page suddenly saw someone on the internet with rose petals to spell 5,213 numbers, suddenly feel good romantic, because every boy will inadvertently become a romantic manufacturer. Since then, the time to go everywhere can see 5, 2, 13 numbers, he was angry, and now he wants to know how many of the consecutive number of the total contains the three numbers. For example, 12356 even one, and 5111 does not count. In particular, if he sees 5,213 numbers appearing in succession, it will be particularly furious. For example 35210.

Input
multiple sets of test data:
A row is given a two number, A, B (0<a,b<1000000), which represents the start and end of a number.
Output
a row shows a few of the numbers he wants to know and shows how many figures make him particularly angry. separated by a space.
Sample input
 $  -  -  the 1  -

Sample output
1:202:213:  61

Source
Fleeting
1#include <stdio.h>2#include <string.h>3#include <stdlib.h>4 Charch[ -];5 intbiao[2][1000100];6 intMain ()7 {8     intI,total=0, sum=0;9memset (Biao,0,sizeof(Biao));Ten      for(i=1;i<1000001; i++) One     { Asprintf (CH,"%d", i); -         if(Strstr (CH,"1")!=NULL&AMP;&AMP;STRSTR (CH,"2")!=NULL&AMP;&AMP;STRSTR (CH,"5")!=NULL) -sum++; the         if(Strstr (CH,"521")!=NULL) -total++; -biao[0][i]=sum; -biao[1][i]=Total ;  +     } -     inta,b,k=1; +      while(~SCANF ("%d%d",&a,&b)) A     { atprintf"Case %d:%d%d\n", k,biao[0][b]-biao[0][a-1],biao[1][b]-biao[1][a-1]);//because this side wrong without several times, can be understood as to meet the conditions of the number of labels, 0[0].1[1].2[1],3[3] num[3]-num[2] should be 1, because the subscript here is the counter (satisfies the condition is 1, not 2), so to use [A-1];  -k++; -     }     -     return 0;  -}

Nanyang 975--about 521 (play table)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.