CodeForces - 620B Grandfather Dovlet’s calculator(遍历)
题目:传送门
思路: 把0~9都直接手算出来,从a到b逐个遍历,每个数都拆分,更新sum值即可.
#include <iostream>
#include <map>
using namespace std;map<int,int> s;
int sums (int x) { // 计算单个数需要的段.int ans = 0;s[0] = 6;s[1]=2;s[2]=5;s[3] = 5;s[4] = 4;s[5] = 5;s[6] =6;s[7]=3;s[8] =7;s[9]=6;if(x==0) return s[x];else {while(x!=0) {ans+=s[x%10];x/=10;}return ans;}
}int main() {int a,b;cin>>a>>b;int sum = 0;for(int i=a;i<=b;i++) {if(sum<0) cout<<"?"<<endl;sum+=sums(i); } cout<<sum<<endl;return 0;
}
CodeForces - 620B Grandfather Dovlet’s calculator(遍历)相关推荐
- Codeforces-Edu6-B. Grandfather Dovlet’s calculator
B. Grandfather Dovlet's calculator time limit per test1 second memory limit per test256 megabytes in ...
- B. Grandfather Dovlet’s calculator【水题】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- CodeForces 620 B. Grandfather Dovlet’s calculator(水~)
Description 在电子表上每个数字的显示情况如下图,先给出两个整数a和b,问表示出区间[a,b]中所有数需要多少个黑段 Input 两个整数a和b(1<=a<=b<=10^6 ...
- 2016区域赛前冲刺训练
UPD 2016.10.23 shift-and (2题) Codeforces 训练 现在已经完成了: 191 [Codeforces Round #377] (6/6) Div 2 A Buy a ...
- Educational Codeforces Round 37 (Rated for Div. 2) E. Connected Components? 暴力 + 补图的遍历
传送门 文章目录 题意: 思路: 题意: n≤2e5,m≤2e5n\le2e5,m\le2e5n≤2e5,m≤2e5. 思路: 这是题是我上个题的一部分,算是个小知识点,暴力能过. 直接维护一个set ...
- Codeforces 982 C. Cut 'em all! 图的遍历
点击打开链接 C. Cut 'em all! time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #506 (Div. 3)
Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...
- Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)
Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...
- 【Codeforces】908B New Year and Buggy Bot(暴力+全排列)
http://codeforces.com/contest/908/problem/B 0 1 2 3 可以对应 上下左右.(具体哪个对应哪个,试过才知道) str 的 长度 为 100,0 1 2 ...
最新文章
- 如何得到iterator的当前元素_Java中迭代器Iterator详解
- 基于python3的一次简单的请求url接口返回json类型结果实例。
- 超多干货!支撑起腾讯公司计费业务的TDSQL(附PPT)
- springboot md5加密_SpringSecurity入门-SpringBoot集成SpringSecurity
- C++中堆和栈的完全解析
- python 简单trace 过滤处理
- UTF-8, ASCII, Unicode的介绍与区分
- Linux编程(11)_信号
- 新的一年,这7个“菜鸟坑”千万别再踩了!
- ASP.NET MVC:实现我们自己的视图引擎
- 《AngularJS高级程序设计》学习笔记
- 基于JDK1.8的JVM 内存结构【JVM篇三】
- Win 10 专业版重新激活详细操作步骤
- Js解决微信浏览器刷新的问题
- 肠道重要菌属——嗜胆菌属 (Bilophila)喜欢脂肪、耐胆汁的促炎菌
- No rule to make target
- 机器学习(八):CS229ML课程笔记(4)——生成学习,高斯判别分析,朴素贝叶斯
- 加速器 (Accelerator or Offload Engine)
- python系列之---python的起源
- vue 组件,props 属性 ,Vue 生命周期
热门文章
- 合肥市直计算机知识pdf,事业单位计算机基础知识题库(全).pdf
- 毕设 房地产客服管理系统论文
- 使用python计算马哈顿距离、切比雪夫距离、欧式距离、夹角余弦
- 【ANSYS 学习笔记】Case04_Basic DC Conduction Analysis
- 基于 function-plot.js 开源库绘制数学函数图像实现兼文档翻译
- 2023年的一些规划和想法
- 商业银行清算业务(一)
- 单招计算机试题出处,2017年职业技术学院单独招生综合素质测试试题库及答案...
- (数据结构)图——图、顶点、无向边、无向图、有向边、有向图、简单图、无向完全图、有向完全图、稀疏图、稠密图、权、网、子图的相关概念
- python中scale的用法_在netCDF4和Python中使用scale_factor和add_offset的示例?