Win8 is forbidden to buy information war from dark to Ming

Source: Internet
Author: User

Question c:repeat number

:  1 SEC   memory limit :  128 MB
submit :   23   Resolve :  7 Span style= "Color:rgb (51,51,51)" >
[ submit ][ status [ forum ]

Title Description

definition:a+b = c, if all the digits of C being same (c is more than ten) , Then we call A and B is Repeat number. My question is what many Repeat Numbers in [x, Y].

Input

There is several test cases.

Each test cases contains the integers x, y (1<=x<=y<=1,000,000) described above.

Proceed to the end of file.

Output

For each test output, the number of couple of Repeat number in one line.

Sample input

1 10 10 12

Sample output

5 2

Tips

If a equals B, we can call a, b be Repeat Numbers too, and A is the Repeat Numbers for itself.

This problem, I was violent plus two points, the enumeration of the possible values of C can be. Then we can find the minimum value of the middle point and the boundary difference.


#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <    Cmath> #include <vector>using namespace std;vector<int> g;void init () {int k=1;        for (int i=0;i<6;i++) {k=k*10+1;    for (int j=1;j<=9;j++) g.push_back (K*J);    }}int Main () {int x, y;    Init ();        while (cin>>x>>y) {int p=lower_bound (G.begin (), G.end (), 2*x)-g.begin ();        int Q=lower_bound (G.begin (), G.end (), 2*y)-g.begin ();        int ans=0;        for (int i=0;i<10;i++)//cout<<g[i]<<endl;       if (g[q]>2*y) q--;        cout<<p<< "" <<q<<endl;            for (int i=p;i<=q;i++) {int mid = G[I]/2; if (mid* 2 = = G[i]) ans + = Mid-x < Y-mid?            mid-x+1:y-mid+1; else ans+= mid-x+1 < y-mid?        Mid-x+1:y-mid;    } cout<<ans<<endl; } return 0;}


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.