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;}