标签:des style blog color os io 数据 for
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, 467are not.
Petya has an array consisting of n numbers. He wants to perform m operations of two types:
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.
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.
For each operation of the second type print the single number on the single line — the number of lucky numbers in the corresponding interval.
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
0
1
1
题意:给出一组序列然后找出区间lcuk数字的个数。
sl: 线段树树状数组第一时间确定是这个数据结构,剩下的就不会了。
扫了一眼题解发现都是树状数组暴力搞得。时间快的就是线段树加一个优化。
优化: 维护区间内的数字到达一个luck数字的最小距离。要是区间修改之后不能使得最小的距离变为0 那么就直接lazy修改下区间luck距离的最小值。
要是超过了,那么就递归到叶子节点直接修改。 时间复杂度我在研究研究。
113 }
Codeforces Beta Round #91 (Div. 1 Only) E. Lucky Array,布布扣,bubuko.com
Codeforces Beta Round #91 (Div. 1 Only) E. Lucky Array
标签:des style blog color os io 数据 for
原文地址:http://www.cnblogs.com/acvc/p/3887540.html