当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4382:Harry Potter and Cyber Sequence Generator

题目描述
After Voldemort and the Death Eater were wiped out by Harry Potter and his friends, Harry becomes the glory of the Wizarding World, magician treat him as model, hero, king… and much more than that.
   Recently Harry Potter and his friends have been researching a kind of toy from the Muggle World, with the name Cyber Sequence Generator, wondering if after manipulated in some certain way, it can be useful and powerful for magicians.
  This kind of generator has two magic containers C1 and C2, if we put a magic element in C1, after its magic is all over, the result magic element can be taken from C2. Because we Muggles(I’m sorry if you are not a muggle, you can ask me for magic student version of this problem statement even you are competing and can’t use the Internet) do not know magic languages, let’s rearrange the words to describe how the generator works.
  The generator’s work can be split into simple works. Each work is like:

SET|ADD C1|C2, C1|C2|IntegerNumber
MUL C1|C2, IntegerNumber

By “SET a,b “, we have the value of the element in container a changed to b
By “ADD a,b “, we have the value of the element in container a added by b
By “MUL a,b “, we have the value of the element in container a multiplied by b
After each of the operations, the value in b will not change.
  Here C1, C2 denotes actually the value of magic element.
C2’s initial value is 0.
  All works are done in the order in input.
  
  Harry always has a magic element V at first, and can use the generator arbitary times, and wonders if so, what is the value of the result element.
输入解释
  One line T, the number of test cases.
  For each test case, first line contains one integer V. Then a few lines describe the Cyber Sequence Generator, ended by “END”.
  Then an integer Q, the number of Queries.
  Q number following describe how many times Harry use the generator, for each query N , we have the initial value is V, and C2’s initial value is 0.
  The instruction is like "SET_a,_b".(underscore '_' is just used to demonstrate blank char)
输出解释
  For each test case, first output a line "Case num:", while num is the case number, based on 1. There is one space between 'Case' and 'num' and no more blanks in the same line.
  
For each query, output a line of the value of the result magic element, modulo prime p = 109+7(i.e 1 000 000 007).
  
Constraints
1<=T<=10
1<=N<=10100
1<=Q<=100
  One generator has no more than 100 instructions.
  All integer constants in SET/ADD/MUL instruction will fit 32-bit integer type.
输入样例
2
1
ADD C1, 1
SET C2, C1
END
5
1
2
3
4
5
1
ADD C1, C1
SET C2, 1
ADD C2, C1
SET C1, C2
END
5
1
2
3
4
5
输出样例
Case 1:
2
3
4
5
6
Case 2:
3
7
15
31
63
来自杭电HDUOJ的附加信息
Author WHU
Recommend zhuyuanchen520

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4382

最后修改于 2020-10-25T23:12:59+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)