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 ...
随机推荐
- js写的数码时钟,在“最小化”浏览器 或者 “切换网页”是动画效果好像不对
一.问题 在“最小化”浏览器 或者 “切换网页”是动画效果不对,不知道哪里出了问题???是不是”最小化“时网页定时器关掉了,还是其他什么原因啊 ???? 二.HTML代码如下 <div id=& ...
- HTML+JS = 网站注册界面源代码
本注册页面未设置编码方式和兼容性,已测试,在Chrome浏览器显示正常 <!DOCTYPE html> <html> <head> <title>注册页 ...
- 【机器学习】多项式回归sklearn实现
[机器学习]多项式回归原理介绍 [机器学习]多项式回归python实现 [机器学习]多项式回归sklearn实现 使用sklearn框架实现多项式回归.使用框架更方便,可以少写很多代码. 使用一个简单 ...
- SpringBoot在IntelliJ IDEA下for MAC 热加载
说在前面 热加载:文件内容变更服务器自动运行最新代码.实则在IDEA环境进行热部署后,下述过程一气呵成. 1代码变更,文件自动保存(IDEA自动保存代码,用户无需使用COMMAND+SAVE快捷键): ...
- codeforces 303C. Minimum Modular(数论+暴力+剪枝+贪心)
You have been given n distinct integers a1, a2, ..., an. You can remove at most k of them. Find the ...
- ZOJ 3689 Digging(DP)
Description When it comes to the Maya Civilization, we can quickly remind of a term called the end o ...
- 搭建github
http://www.cnblogs.com/liuxianan/p/build-blog-website-by-hexo-github.html
- 【Docker】- 基本命令
1.docker ps -a 显示所有容器 2.doker ps -l 显示最近一次启动的容器 3.docker ps 显示正在运行的容器 4.docker start [容器ID] 启动 ...
- 实现一个可以实时提示的textarea组件
该组件输入.换行.变换光标可以实时给出提示 效果: textarea.vue <template> <div> <el-input id="user-input ...
- QT分析之网络编程
原文地址:http://blog.163.com/net_worm/blog/static/127702419201002842553382/ 首先对Windows下的网络编程总结一下: 如果是服务器 ...