問題 C: Repeat Number
時間限制: 1 Sec 內存限制: 128 MB
提交: 23 解決: 7
[提交][狀態][論壇]
題目描述
Definition: a+b = c, if all the digits of c are same ( c is more than ten),then we call a and b are Repeat Number. My question is How many Repeat Numbers in [x,y].
輸入
There are several test cases.
Each test cases contains two integers x, y(1<=x<=y<=1,000,000) described above.
Proceed to the end of file.
輸出
For each test output the number of couple of Repeat Number in one line.
樣例輸入
1 10 10 12
樣例輸出
5 2
提示
If a equals b, we can call a, b are Repeat Numbers too, and a is the Repeat Numbers for itself.
這道題,我是暴力加二分過的,枚舉c的可能值即可。然後求中間點與邊界差的最小值即可
#include#include #include #include #include #include using namespace std; vector 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< 2*y) q--; // cout<