A1171 | [COCI-2008_2009-contest5]#6 TRESNJA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Lana lives in a small but merry village. There is a row of cherry trees next to the main street. Lana numbered the trees with consecutive integers starting with
1.
After much studying, Lana noticed that the number of the tree uniquely determines the amount of cherries the tree gives.
For one tree, consider consecutive groups of digits in the tree's number. For each group of digits, multiply the digit by the square of the length of the group. Adding these numbers for all groups gives the total number of cherries the tree gives.
For example, in tree number 77744007, the groups are 777, 44, 00 and
7. The amount of cherries will be 7·3^2 + 4·2^2 + 0·2^2 + 7·1^2 = 86 units.
The time has come to pick the cherry trees and the villagers have agreed to pick all trees numbered A through B (inclusive). Write a program that will calculate the total amount of cherries picked.
1.
After much studying, Lana noticed that the number of the tree uniquely determines the amount of cherries the tree gives.
For one tree, consider consecutive groups of digits in the tree's number. For each group of digits, multiply the digit by the square of the length of the group. Adding these numbers for all groups gives the total number of cherries the tree gives.
For example, in tree number 77744007, the groups are 777, 44, 00 and
7. The amount of cherries will be 7·3^2 + 4·2^2 + 0·2^2 + 7·1^2 = 86 units.
The time has come to pick the cherry trees and the villagers have agreed to pick all trees numbered A through B (inclusive). Write a program that will calculate the total amount of cherries picked.
输入格式
Input consists of two integers A and B (1 ≤ A ≤ B ≤ 10^15), the first and last trees to be picked.
输出格式
Output a single integer, how many units of cherries will be picked.
输入输出样例
输入 #1
1 9
输出 #1
45
输入 #2
100 111
输出 #2
68
输入 #3
7774407 7774407
输出 #3
86
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted