# Codeforces Round #129 (Div. 2) C

Source: Internet
Author: User

Description

The Little Elephant very much loves sums on intervals.

This time he has a pair of Integers  l  and  R   ( l R ). The Little Elephant have to find the number of such integers  x   ( l x R ), that the first digit of Integer  x & Nbsp;equals the last one (in decimal notation). For example, such numbers as 101, 477474 or < Span class= "Tex-span" >9 will be included in the answer And47,  253 or 1020 will not.

Help him and count the number of described numbers x for a given pair l and R.

Input

The single line contains a pair of integers l and R (1≤ lR ≤10 18)-the boundaries of the interval.

%lld specifier to read or write 64-bit integers inс++. It is preferred to use cin, cout streams or the %i64dspecifier.

Output

On a single line print a single integer-the answer to the problem.

Examples input
`2 47`
Output
`12`
input
`47 1024`
Output
`98`
Note

In the first sample, the answer includes integers 2, 3, 4, 5, 6, 7, 8, 9, one,,.

Test instructions: With this number, the first and the last one are the same, asking you how many numbers meet the required number in the two number range ~

Solution: Of course, is to find the law, it is easy to see the law is 9*10^n, and then consider the situation of two endpoints, they are not also meet the requirements (here the code is not clear Qaq, the most valuable only the CMD function)

`#include <bits/stdc++.h>using namespace Std;long long a;int pos;int n;int d;long long cmd (string s) {long    Long sum1=0,sum2=0;    if (S.length () ==1) {sum1=0;    } else if (S.length () ==2) {sum1=9;        } else {sum1=10;        for (int i=1;i<s.length () -2;i++) {sum1*=10;        }//cout<<sum1<<endl;      Sum1=sum1-1;        cout<<sum1<<endl;    sum1+=9;    } int ans1=s-' 0 '-1;    Long Long sum3=0;    Long Long pos1=1;        if (S.length () >=3) {for (int i=1; I<=s.length ()-2; i++) {sum3=sum3*10+ (s[i]-' 0 ');        }//Sum3=sum3+1;        for (int i=0; I<s.length ()-2; i++) {pos1*=10;        } if ((s-' 0 ') <= (s[s.length () -1]-' 0 ')) {sum1=sum1+ans1*pos1+sum3+1;        } else {sum1=sum1+ans1*pos1+sum3;        }} else {if (S<=s[s.length ()-1]){sum1=sum1+ans1*pos1+sum3+1;        } else {sum1=sum1+ans1*pos1+sum3; }} return sum1;}    int main () {string s1,s2;   cin>>s1>>s2;   Cout<<cmd (S1) <<endl;    Cout<<cmd (S2) <<endl;    if (S1==s1[s1.length () -1]&&s2<=s2[s2.length ()-1]) {cout<<cmd (s2)-cmd (S1) +1<<endl; } else if (S1==s1[s1.length () -1]&&s2>s2[s2.length ()-1]) {cout<<cmd (s2)-cmd (S1) +1<    <endl; } else if (S1<=s1[s1.length () -1]&&s2<=s2[s2.length ()-1]) {cout<<cmd (s2)-cmd (S1) <    <endl; } else if (S1<=s1[s1.length () -1]&&s2>s2[s2.length ()-1]) {cout<<cmd (s2)-cmd (S1) <&    Lt;endl; } else if (S1>s1[s1.length () -1]&&s2<=s2[s2.length ()-1]) {cout<<cmd (s2)-cmd (S1) <&    Lt;endl; } else if (S1>s1[s1.length () -1]&&s2>s2[s2.leNgth ()-1]) {cout<<cmd (s2)-cmd (S1) <<endl; } else if (S1>s1[s1.length () -1]&&s2<=s2[s2.length ()-1]) {cout<<cmd (s2)-cmd (S1) <&    Lt;endl; } return 0;}`

Codeforces Round #129 (Div. 2) C

Related Keywords:
Related Article

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.