B. Grandfather Dovlet’s calculator
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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.

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.

Sample test(s)
input
1 3
output
12
input
10 15
output
39

简单题,根据题意直接做就行;
代码如下:

#include <bits/stdc++.h>
using namespace std;
int main()
{int sum=0,i,a,b,y,n;cin>>a>>b;for(i=a;i<=b;i++){n=i;while(n){y=n%10;n=n/10;switch(y){case 0:sum+=6;break;case 1:sum+=2;break;case 2:sum+=5;break;case 3:sum+=5;break;case 4:sum+=4;break;case 5:sum+=5;break;case 6:sum+=6;break;case 7:sum+=3;break;case 8:sum+=7;break;case 9:sum+=6;break;} }}cout<<sum;
}

仅代表个人观点,不喜勿喷!

Codeforces-Edu6-B. Grandfather Dovlet’s calculator相关推荐

  1. CodeForces 620 B. Grandfather Dovlet’s calculator(水~)

    Description 在电子表上每个数字的显示情况如下图,先给出两个整数a和b,问表示出区间[a,b]中所有数需要多少个黑段 Input 两个整数a和b(1<=a<=b<=10^6 ...

  2. B. Grandfather Dovlet’s calculator【水题】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  3. CodeForces - 620B Grandfather Dovlet’s calculator(遍历)

    题目:传送门 思路: 把0~9都直接手算出来,从a到b逐个遍历,每个数都拆分,更新sum值即可. #include <iostream> #include <map> usin ...

  4. 2016区域赛前冲刺训练

    UPD 2016.10.23 shift-and (2题) Codeforces 训练 现在已经完成了: 191 [Codeforces Round #377] (6/6) Div 2 A Buy a ...

  5. Codeforces Round #597 (Div. 2) - BenFromHRBUST

    Codeforces Round #597 (Div. 2) -----比赛传送门----- A - Good ol' Numbers Coloring Problem Description Con ...

  6. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

  7. 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

    题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...

  8. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

  9. CodeForces 获得数据

    针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. 1 for (i=1;i<=q;i++) 2 { 3 scanf ...

最新文章

  1. 使用ant进行junit测试
  2. ABAP选择屏幕的例子
  3. 【bzoj3514】 Codechef MARCH14 GERALD07加强版
  4. Eclipse安装Alibaba Cloud Toolkit并连接阿里云云数据库
  5. 深度增强学习--Actor Critic
  6. MySQL update For_mysql SELECT FOR UPDATE语句使用示例
  7. easyui textbox获取焦点事件
  8. jsp实现简易计算器
  9. Nvidia显卡驱动升级
  10. 几款swf flv flash网页播放器
  11. MyFirefox v2.6.2 - 打造自己的 Firefox 便携版
  12. 前端分页加载功能实现?
  13. Python+Pyecharts实现1995~2020世界人口分析报告
  14. 办公效率该怎么提高呢?五个高效办公小技巧分享给你,职场的你必备的神器。
  15. android分辨率 尺寸 dpi换算
  16. Java项目如何查找各种jar包
  17. 解决element-ui/element-plus中el-pagination分页组件显示英文
  18. 去哪儿网——项目管理平台助力研发效率提升
  19. 解决uniapp引入字体图标不显示问题
  20. 如何利用python刷微博粉丝最多的明星_新手用微博,如何迅速增大粉丝数量?

热门文章

  1. U盘防拷精灵 v1.3
  2. python 协程之异步下载图片
  3. 车联网解决方案-最新全套文件
  4. Latex Misplaced alignment tab character . 的一种可能错误
  5. SQL Sever报错,无法连接到服务器
  6. simpack车轮不圆
  7. 计算机二级考试模拟试题及答案,计算机二级考试模拟试题及答案
  8. matlab道路检测,基于MATLAB的车道保持辅助车道检测
  9. 成功将log4cpp升级到了vs2005版本,总结下编译时报错及相应的解决方法
  10. Unity简单商城系统,用SQLite数据库保存/加载数据