A8342 | Lucky Array
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has an array consisting of $n$ numbers. He wants to perform $m$ operations of two types:
- add $l$ $r$ $d$ — add an integer $d$ to all elements whose indexes belong to the interval from $l$ to $r$ , inclusive $(1<=l<=r<=n,1<=d<=10^{4})$ ;
- count $l$ $r$ — find and print on the screen how many lucky numbers there are among elements with indexes that belong to the interval from $l$ to $r$ inclusive $(1<=l<=r<=n)$ . Each lucky number should be counted as many times as it appears in the interval.
Petya has a list of all operations. The operations are such that after all additions the array won't have numbers that would exceed $10^{4}$ . Help Petya write a program that would perform these operations.
Petya has an array consisting of $n$ numbers. He wants to perform $m$ operations of two types:
- add $l$ $r$ $d$ — add an integer $d$ to all elements whose indexes belong to the interval from $l$ to $r$ , inclusive $(1<=l<=r<=n,1<=d<=10^{4})$ ;
- count $l$ $r$ — find and print on the screen how many lucky numbers there are among elements with indexes that belong to the interval from $l$ to $r$ inclusive $(1<=l<=r<=n)$ . Each lucky number should be counted as many times as it appears in the interval.
Petya has a list of all operations. The operations are such that after all additions the array won't have numbers that would exceed $10^{4}$ . Help Petya write a program that would perform these operations.
输入格式
The first line contains two integers $n$ and $m$ ( $1<=n,m<=10^{5}$ ) — the number of numbers in the array and the number of operations correspondingly. The second line contains $n$ positive integers, none of which exceeds $10^{4}$ — those are the array numbers. Next $m$ lines contain operations, one per line. They correspond to the description given in the statement.
It is guaranteed that after all operations are fulfilled each number in the array will not exceed $10^{4}$ .
It is guaranteed that after all operations are fulfilled each number in the array will not exceed $10^{4}$ .
输出格式
For each operation of the second type print the single number on the single line — the number of lucky numbers in the corresponding interval.
输入输出样例
输入 #1
3 6 2 3 4 count 1 3 count 1 2 add 1 3 2 count 1 3 add 2 3 3 count 1 3
输出 #1
1 0 1 1
输入 #2
4 5 4 4 4 4 count 1 4 add 1 4 3 count 1 4 add 2 3 40 count 1 4
输出 #2
4 4 4
In the first sample after the first addition the array will look in the following manner:
4 5 6
After the second addition:
4 8 9
The second sample after the first addition:
7 7 7 7
After the second addition:
7 47 47 7
4 5 6
After the second addition:
4 8 9
The second sample after the first addition:
7 7 7 7
After the second addition:
7 47 47 7
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted