logo AlgoBeat OnlineJudge
登录 注册

#216412. [SYSUCPC 2025] Divisor Transformation

内存限制:256 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

is studying a permutation of length (i.e., contains each integer from to exactly once). He performs experiments, each defined by parameters .

In each experiment, he processes the subarray sequentially. Starting with value , for each element in the subarray:

  • If ( divides ), then becomes
  • Else if ( divides ), then becomes
  • Otherwise, remains unchanged

needs your help to compute:

  • The final value of after processing each experiment
  • The total number of times either or was satisfied during the process

输入格式

The first line contains two integers

The second line contains distinct integers

The next lines each contain 3 integers

输出格式

For each experiment, output two integers:

  • The final value of
  • The total count of cases where either or

样例

样例输入 1

6 6
1 4 3 2 5 6
1 6 4
3 4 2
3 4 4
5 5 1
2 5 3
6 6 4

样例输出 1

2 4
1 1
2 1
5 1
2 2
4 0