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 ...
随机推荐
- leetcode合并区间
合并区间 给出一个区间的集合,请合并所有重叠的区间. 示例 1: 输入: [[1,3],[2,6],[8,10],[15,18]] 输出: [[1,6],[8,10],[15,18]] 解释: ...
- adb 在windows7中的使用
我的系统环境是win7 x64 首先放上资源链接:https://pan.baidu.com/s/1eTV5qX8 密码:2ejw 第一步: 配置环境变量,将adb.exe的路径添加到PATH里面去: ...
- Memcache的客户端连接系列(二) Python
关键词: Memcached Python 客户端 声明:本文并非原创,转自华为云帮助中心的分布式缓存服务(Memcached)的用户指南.客户端连接方法通用,故摘抄过来分享给大家. Python ...
- 今日头条 2018 AI Camp 5 月 26 日在线笔试编程题第一道——最佳路径
题目 给定一个 n*m 的矩阵 A ,矩阵中每一个元素为一个十六进制数.寻找一条从左上角都右下角的路径,每次只能向右或者向下移动, 使得路径上所有数字之积在 16 进制下的后缀 0 最少. 输入描述: ...
- hibernate 异常a different object with the same identifier value was already associated with the session
在使用hibernate的时候发现了一个问题,记录一下解决方案. 前提开启了事务和事务间并无commit,进行两次save,第二次的时候爆出下面的异常a different object with t ...
- javascript打开新窗口
一.window.open()支持环境: JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+ 二.基本语法: window.open(pageURL,name, ...
- HDU 3726 Graph and Queries(平衡二叉树)(2010 Asia Tianjin Regional Contest)
Description You are given an undirected graph with N vertexes and M edges. Every vertex in this grap ...
- Crawling is going on - Beta版本测试报告
[Crawling is going on - Beta版本] 测试报告 文件状态: [] 草稿 [√] 正式发布 [] 正在修改 报告编号: 当前版本: 2.0.2 编写人: 周萱.刘昊岩.居玉皓 ...
- UVALive - 6868 Facility Locations 想法题
题目链接: http://acm.hust.edu.cn/vjudge/problem/88634 Facility Locations Time Limit: 3000MS 题意 给你一个m*n的矩 ...
- Swift-函数的理解
/* 函数(Function) 函数是为执行特定功能的自包含的代码块.函数需要给定一个特定标识符(名字),然后当需要的时候, 就调用此函数来执行功能. */ // 函数的定义与调用 // 定义函数时, ...