【Educational Codeforces Round 6B】【暴力】Grandfather Dovlet’s calculator 区间所有数的火柴总成本

B. Grandfather Dovlet’s calculator
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display).

【Educational Codeforces Round 6B】【暴力】Grandfather Dovlet’s calculator 区间所有数的火柴总成本_第1张图片

Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the total number of segments printed on the calculator.

For example if a = 1 and b = 3 then at first the calculator will print 2 segments, then — 5 segments and at last it will print 5 segments. So the total number of printed segments is 12.

Input

The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max.

Output

Print the only integer a — the total number of printed segments.

Examples
input
1 3
output
12
input
10 15
output
39

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=0,M=0,Z=1e9+7,ms63=0x3f3f3f3f;
int v[10]={6,2,5,5,4,5,6,3,7,6};
int a,b;
int main()
{
	while(~scanf("%d%d",&a,&b))
	{
		int ans=0;
		for(int i=a;i<=b;++i)
		{
			int x=i;
			while(x)
			{
				ans+=v[x%10];
				x/=10;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}


你可能感兴趣的:(水题,codeforces,暴力,题库-CF)