Educational Codeforces Round 6 B
1 second
256 megabytes
standard input
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).
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.
The only line contains two integers a, b (1 ≤ a ≤ b ≤ 106) — the first and the last number typed by Max.
Print the only integer a — the total number of printed segments.
1 3
12
10 15
39 题意: 0-9分别如图所示 每个数字led管由7部分组成 根据不同的数字亮不同的地方
给一个区间 问这段区间内所有数 得有多少部分亮
题解: 每位每位的计算 我的代码998ms
#include<bits/stdc++.h>
using namespace std;
#define LL __int64
map<int,int>mp;
map<int,int>mpp;
int n,m;
int main()
{
mp[0]=6;
mp[1]=2;
mp[2]=5;
mp[3]=5;
mp[4]=4;
mp[5]=5;
mp[6]=6;
mp[7]=3;
mp[8]=7;
mp[9]=6;
mpp[0]=0;
int sum=0;
for(int i=1;i<=1000000;i++)
{
int exm=i;
mpp[i]=sum;
while(exm!=0)
{
mpp[i]+=mp[exm%10];
sum+=mp[exm%10];
exm=exm/10;
}
}
scanf("%d%d",&n,&m);
printf("%d\n",mpp[m]-mpp[n-1]);
return 0;
}
我晏的代码62ms
#include <cstdio>
#include<bits/stdc++.h>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int N = 1000001;
ll H[N][11],a,b;
int M[20] = {6,2,5,5,4,5,6,3,7,6};
int main() {
for(int i = 1; i <= 1000000; i++) {
int tmp = i;
while(tmp) H[i][tmp%10]++,tmp/=10;
}
ll ans = 0 ;
scanf("%I64d%I64d",&a,&b);
for(int i = a; i <= b; i++) {
for(int j = 0; j <= 9 ; j ++) ans+= M[j] * H[i][j];
}
printf("%I64d\n",ans);
return 0;
}
orzzz
Educational Codeforces Round 6 B的更多相关文章
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- [Educational Codeforces Round 16]C. Magic Odd Square
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...
- [Educational Codeforces Round 16]B. Optimal Point on a Line
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...
- [Educational Codeforces Round 16]A. King Moves
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
- Educational Codeforces Round 9
Educational Codeforces Round 9 Longest Subsequence 题目描述:给出一个序列,从中抽出若干个数,使它们的公倍数小于等于\(m\),问最多能抽出多少个数, ...
- Educational Codeforces Round 37
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
随机推荐
- Siki_Unity_2-10_数据结构与算法
Unity 2-10 数据结构与算法 任务1-1:数据结构简介 数据结构:数据存储的结构,数据之间的关系 数据结构分类: 集合:同属于一个集合 线性结构:数据元素存在一对一的关系 树形结构:数据元素存 ...
- iis 10 重新注册iis
iis 10 使用该命令 提示 版本不支持 C:\WINDOWS\system32>c:\windows\microsoft.net\framework64\v4.0.30319\aspnet_ ...
- 【转】Angular.js VS. Ember.js:谁将成为Web开发的新宠?
本文源自于Quora网站的一个问题,作者称最近一直在为一个新的Rails项目寻找一个JavaScript框架,通过筛选,最终纠结于 Angular.js和 Ember.js. 这个问题获得了大量的关注 ...
- 面试中要注意的 3 个 JavaScript 问题
JavaScript 是 所有现代浏览器 的官方语言.因此,各种语言的开发者面试中都会遇到 JavaScript 问题. 本文不讲最新的 JavaScript 库,通用开发实践,或任何新的 ES6 函 ...
- Repair the Wall (贪心)
Long time ago , Kitty lived in a small village. The air was fresh and the scenery was very beautiful ...
- 【转载】【翻译】Breaking things is easy///机器学习中安全与隐私问题(对抗性攻击)
原文:Breaking things is easy 译文:机器学习中安全与隐私问题(对抗性攻击) 我是通过Infaraway的那篇博文才发现cleverhans-blog的博客的,这是一个很有意思的 ...
- Swift-创建UIButton(其他UI组件雷同)
let button = UIButton.init(frame: CGRectMake(, , , )) button.setTitle("按钮", forState: UICo ...
- js实现倒计时60秒的简单代码
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Conten ...
- 【转】log4j.properties文件的配置
一.前言 log4j使用的还是比较多的,但是对于其配置又很难描述清楚要怎么配置,说明我自己对于log4j的配置并不是非常熟悉,所以在网上找了一篇详尽的 博文转载,在此非常感谢原文作者的辛苦付出,如有需 ...
- 累积下学习 C#时和 Java时的不同点
==和equals()方法的区别: 首先有一个观点: 这两个都是用来比较值是否相等的 ( 这里的值有时候指的是地址值, 有时候是存储的值; 下面将地址值称为地址, 存储的值称为值 ) 在Java中: ...