201485: [AtCoder]ARC148 F - 998244353 → 1000000007

Memory Limit:1024 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $1000$ points

Problem Statement

This problem is output-only.

We have a programming language equipped with the following operations of unsigned 64-bit integers: addition, multiplication, and a modulo operation where the divisor is $998244353$.
Write a program that performs multiplication modulo $1000000007$ in this language.

More formally, write a program that receives integers $a$ and $b$ between $0$ and $1000000006$ and computes $a \times b \bmod{1000000007}$ under the following Specification and Format.

Specification

The program can handle $26$ variables represented by uppercase English letters: $A, B, \dots, Z$.
Each variable can hold an integer value between $0$ and $2^{64}-1$ (inclusive). Below, such a value is called unsigned 64-bit integer.
At the start of the execution of the program, $A$ is assigned an integer $a$, $B$ is assigned an integer $b$, and the other variables are assigned $0$.
At the end of the execution, $C$ must hold $a \times b \bmod{1000000007}$.

Format

The $1$-st line of the program contains an integer $N$ $(1 \leq N \leq 100)$ representing the number of instructions in the program.
The $2$-nd through $(N + 1)$-th lines contain $N$ instructions. The instructions are executed one by one from top to bottom.
Each instruction is in one of the following three forms.

  • add x y z
    • Assign $(y + z) \bmod{2^{64}}$ to $x$, where $x$ is a variable, and each of $y$ and $z$ is a variable or an unsigned 64-bit integer.
  • mul x y z
    • Assign $(y \times z) \bmod{2^{64}}$ to $x$, where $x$ is a variable, and each of $y$ and $z$ is a variable or an unsigned 64-bit integer.
  • rem x y
    • Assign $y \bmod{998244353}$ to $x$, where $x$ is a variable, and $y$ is a variable or an unsigned 64-bit integer.

Input

The input given from Standard Input is empty.

Output

Print a program under the Specification and Format.

Judging

If the submitted program is malformed, the verdict will be indeterminate.
If the submitted program is well-formed, for each test case, the judge will execute it against $10^4$ pairs of integers $(a, b)$ $(0 \leq a, b \leq 1000000006)$ independently. (These pairs are prepared beforehand and constant for each test case.)
If the variable $C$ holds $a \times b \bmod{1000000007}$ at the end of the execution for all pairs $(a, b)$, the verdict will be AC; otherwise, it will be WA.

Sample Output

Here is an example of a well-formed program. (The Specification is not satisfied, so it will be judged as WA if submitted.)

5
mul C A B
rem C C
add A A 10
add D 2 B
add E 1 0

At the end of the execution of this program, the variables will hold the following values.

  • $A$: $a + 10$
  • $B$: $b$
  • $C$: $a \times b \bmod{998244353}$
  • $D$: $b + 2$
  • $E$: $1$
  • The others: $0$

Input

题意翻译

**这是一道提交答案题。** hhoppitree 有一台计算机和 $26$ 个**无符号 $\textbf{64}$** 位变量(也就是说,运算过程中所有的计算都会**对** $\textbf 2^{\textbf {64}}$ **取模**),名字分别为 $A\sim Z$。 初始时,$A$ 和 $B$ 中分别存储着两个数 $a$ 和 $b$,他想用以下三种操作使得变量 $C$ 中的值为 $a\times b\bmod 1000000007$: - $\colorbox{f0f0f0}{\verb!add x y z!}$:将变量 $x$ 的值赋为变量 $y$ 的值和变量 $z$ 的值的和。 - $\colorbox{f0f0f0}{\verb!mul x y z!}$:将变量 $x$ 的值赋为变量 $y$ 的值和变量 $z$ 的值的积。 - $\colorbox{f0f0f0}{\verb!rem x y!}$:将变量 $x$ 的值赋为变量 $y$ 的值对 $998244353$ 取模后的值。 请利用以上三种语句写出一个 $\mathbf{100}$ **行以内**的伪代码,使得它能计算出 $a\times b\bmod1000000007$ 的值,并存储在变量 $C$ 中。

加入题单

上一题 下一题 算法标签: