编程介的小学生 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 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿