2014牡丹江网络预选赛E题(线段树)zoj3813
来源:互联网 发布:端口类型 路由器 编辑:程序博客网 时间:2024/03/29 22:15
There is a digit string S with infinite length. In addition, S is periodic and it can be formed by concatenating infinite repetitions of a base string P. For example, if P = 3423537, then S = 3423537342353734235373423537...
Let's define the alternating sum on substrings of S. Assume Sl..r is a substring of S from index l to index r (all indexes are 1-based), then the alternating sum of Sl..r is:
For example, S2..10 = 423537342, then G(2, 10) = 4 - 2 + 3 - 5 + 3 - 7 + 3 - 4 + 2 = -3.
Now, you are given the base string P and you have to do many operations. There are only two kinds of operations:
- 1 x d: set Px to d, d is a single digit.
- 2 l r: find the sum of G(i, j) that l <= i <= j <= r.
For each second operation, you should output the sum modulo 109 + 7.
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains a digit string P (1 <= length(P) <= 100000).
The second line contains an integer Q (1 <= Q <= 100000) indicating the number of operations. Each of the following Q lines is an operation in such format:
- 1 x d (1 <= x <= length(P), 0 <= d <= 9)
- 2 l r (1 <= l <= r <= 1018)
Output
For each "2 l r" operation, output an integer, indicating the sum modulo 109 + 7.
Sample Input
232424242 1 12 1 41 3 72 3 432424262 1 11 3 72 2 41 3 42 7 102 1 30
Sample Output
320143820870
- 2014牡丹江网络预选赛E题(线段树)zoj3813
- 2014牡丹江网络预选赛D题(状压DP)zoj3812
- 2014牡丹江网络预选赛B题(找规律)zoj3810
- 2014牡丹江网络预选赛I题(字符串hash+简单DP)zoj3817
- 2014牡丹江网络预选赛F题(隐式图BFS暴搜)zoj3814
- zoj3813 线段树
- 牡丹江2014网络赛 E zoj—3813 规律与线段树
- ZOJ 3809 The Himalayas (2014 ACM/ICPC 牡丹江站 网络预选赛 A 题)
- ZOJ 3818 The Himalayas (2014 ACM/ICPC 牡丹江站 网络预选赛 J 题)
- ZOJ 3813 Alternating Sum (牡丹江网络赛E题)
- 天津网络预选赛 1007-Giant_For(线段树+set)
- 2014北京网络预选赛1008(线段树区间操作)HDU5039
- 2014 ACM-ICPC亚洲区域赛牡丹江站网络预选赛 CUntrusted Patrol
- 2017武汉大学校赛网络预选赛e题
- zoj 3813 Alternating Sum(2014ACMICPC Regional 牡丹江站网络赛 E)
- zoj 3813 Alternating Sum(2014ACMICPC Regional 牡丹江站网络赛 E)
- 2014鞍山网络预选赛1006(LCT模板题)hdu5002
- zoj3813 Alternating Sum 较难的线段树
- 一个与Linq延迟查询有关的小例子
- QStatusBar类
- winsock两种模式和五种I/O模型
- Haproxy 配置片段记录
- invalid conversion from `void*' to `SeqList*
- 2014牡丹江网络预选赛E题(线段树)zoj3813
- 查看Windows Server端口的连接数
- 用exe4j工具将eclipse生成的jar文件制作成exe文件
- 【android NDK及JNI】ubuntu12.10 64位 + android-ndk-r9 编译ffmpeg遇到的问题 .
- wordpress插件
- Vmware克隆Centos 不能上网的解决方案
- [leetcode] Reverse Nodes in k-Group
- 扩展赋值运算符
- QSettings类详解