CF121E.Lucky Array
提高+/省选-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 ≤ 104);
- 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 104. Help Petya write a program that would perform these operations.
佩佳喜欢幸运数字。众所周知,幸运数字是指十进制表示中仅包含幸运数字 4 和 7 的正整数。例如,47、744、4 是幸运数字,而 5、17、467 不是。
佩佳有一个包含 $ n $ 个数字的数组。他希望执行 $ m $ 个操作,操作分为两类:
add l r d—— 将整数 $ d $ 加到所有下标属于区间 [l,r](含端点)的元素上(1 ≤ l ≤ r ≤ n,1 ≤ d ≤ 104);count l r—— 查询并输出下标属于区间 [l,r](含端点)的元素中,幸运数字的个数(每个幸运数字按其在该区间中出现的次数计数)。
佩佳已有一份全部操作的列表。这些操作保证:在所有加法操作执行完毕后,数组中任意元素的值均不会超过 104。请帮助佩佳编写一个程序来执行这些操作。
输入格式
The first line contains two integers n and m (1 ≤ n, m ≤ 105) — the number of numbers in the array and the number of operations correspondingly. The second line contains n positive integers, none of which exceeds 104 — 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 104.
第一行包含两个整数 n 和 m(1≤n,m≤105)—— 分别表示数组中数字的个数以及操作的个数。
第二行包含 n 个正整数,每个数均不超过 104 —— 这些即为数组中的元素。
接下来 m 行每行描述一个操作,对应题目陈述中所给的操作说明。
保证在所有操作执行完毕后,数组中的每个数均不超过 104。
输出格式
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
第二次添加操作后:
4 8 9
第二个样例中,第一次添加操作后:
7 7 7 7
第二次添加操作后:
7 47 47 7
输入解题思路,AI测评打分。不知道怎么写?