Codeforces Beta Round 91 (Div. 1 Only)
E
Lucky Array
Codeforces
2400
原题
← D→
翻译中…

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.

翻译中…

Input

翻译中…

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}$.

翻译中…

Output

翻译中…

For each operation of the second type print the single number on the single line — the number of lucky numbers in the corresponding interval.

翻译中…

Note

翻译中…

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

翻译中…

样例

Input #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
Output #1
1
0
1
1
InputCopy OutputCopy
Input #2
4 5
4 4 4 4
count 1 4
add 1 4 3
count 1 4
add 2 3 40
count 1 4
Output #2
4
4
4
InputCopy OutputCopy
题目信息
题号
121E
时间限制
4 s
内存限制
256 MB
标签
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。