编程介的小学生 2018-12-11 13:45 采纳率: 20.5%
浏览 592
已采纳

取模运算的题目,实在是不会做,在这里请高手分析下C语言

Problem Description
THE END IS COMINGGGGGG!

Mike has got stuck on a mystery machine. If he cannot solve this problem, he will go to his doom.

This machine is consist of n cells, and a screen. The i-th cell contains a number ai(1≤i≤n). The screen also contains a number s, which is initially 0.

There is a button on each cell. When the i-th is pushed, Mike observes that, the number on the screen will be changed to s+ai, where s is the original number. and the number on the i-th cell will be changed to a2i.

Mike observes that the number is stored in radix p, where p=9223372034707292160. In other words , the operation is under modulo p.

And now, Mike has got a list of operations. One operation is to push buttons between from l-th to r-th (both included), and record the number on the screen. He is tired of this stupid work, so he asks for your help. Can you tell him, what are the numbers recorded.

Input
The first line contains an integer T(T≤5), denoting the number of test cases.

For each test case, the first line contains two integers n,m(1≤n,m≤105).

The next line contains n integers ai(0≤ai<p), which means the initial values of the n cells.

The next m lines describe operations. In each line, there are two integers l,r(1≤l≤r≤n), representing the operation.

Output
For each test case, output ''Case #t:'', to represent this is the t-th case. And then output the answer for each query operation, one answer in a line.

For more details you can take a look at the example.

Sample Input
2
4 4
2 3 4 5
1 2
2 3
3 4
1 4
1 3
2
1 1
1 1
1 1

Sample Output
Case #1:
5
18
39
405
Case #2:
2
6
22

  • 写回答

2条回答 默认 最新

  • threenewbee 2019-06-29 22:08
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)