编程介的小学生 2017-04-05 02:52 采纳率: 20.5%
浏览 696
已采纳

Boring Sequence Operations

There is a sequence of N numbers. Initially, the numbers in the sequence are 0 ... N-1. We'll then do different kinds of operations on it.

The operations could be:

add a b x, add all numbers in the interval [a,b) by x.
mul a b x, multiply all numbers in the interval [a,b) by x.
rot a b x, rotate the numbers in the interval [a,b) to the right by x positions.
rev a b, reverse the numbers in the interval [a,b).
We will query the sum of interval, sum a b means we need the sum of interval [a,b).

All subscripts are 0-based.

For example, when N is 6, after the operation 'rot 2 5 1', the sequence will become 0 1 4 2 3 5. And then take the operation 'mul 3 4 10', the sequence will become 0 1 4 20 3 5. If we query 'sum 0 4' now, the answer should be 25.

Input
About 10 test cases, seperated by blank line.

First line of each case is two integers N (1<=N<=40000000) and M (0<=M<2048). The following M lines are descriptions of operations and queries as the format in problem description.

All numbers are integers. For all operations, 0<=a<b<=N, 0<=x<16.

Output
For each query, output one line indicating the answer mod 9875321.

Output a blank line after each test case.

Sample Input
6 7
rot 2 5 1
mul 3 4 10
sum 0 4
add 0 6 1
sum 0 6
rev 0 6
sum 0 1
Sample Output
25
39
6

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-04-17 15:48
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊