CF1792E.Divisors and Table
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an n×n multiplication table and a positive integer m=m1⋅m2 . A n×n multiplication table is a table with n rows and n columns numbered from 1 to n , where ai,j=i⋅j .
For each divisor d of m , check: does d occur in the table at least once, and if it does, what is the minimum row that contains d .
输入格式
The first line contains a single integer t ( 1≤t≤10 ) — the number of test cases.
The first and only line of each test case contains three integers n , m1 and m2 ( 1≤n≤109 ; 1≤m1,m2≤109 ) — the size of the multiplication table and the integer m represented as m1⋅m2 .
输出格式
For each test case, let d1,d2,…,dk be all divisors of m sorted in the increasing order. And let a1,a2,…,ak be an array of answers, where ai is equal to the minimum row index where divisor di occurs, or 0 , if there is no such row.
Since array a may be large, first, print an integer s — the number of divisors of m that are present in the n×n table. Next, print a single value X=a1⊕a2⊕⋯⊕ak , where ⊕ denotes the bitwise XOR operation.
输入输出样例
输入#1
3 3 72 1 10 10 15 6 1 210
输出#1
6 2 10 0 8 5
说明/提示
In the first test case, m=72⋅1=72 and has 12 divisors [1,2,3,4,6,8,9,12,18,24,36,72] . The 3×3 multiplication table looks like that:
123112322463369 For each divisor of m that is present in the table, the position with minimum row index is marked. So the array of answers a is equal to [1,1,1,2,2,0,3,0,0,0,0,0] . There are only 6 non-zero values, and xor of a is equal to 2 .
In the second test case, m=10⋅15=150 and has 12 divisors [1,2,3,5,6,10,15,25,30,50,75,150] . All divisors except 75 and 150 are present in the 10×10 table. Array a = [1,1,1,1,1,1,3,5,3,5,0,0] . There are 10 non-zero values, and xor of a is equal to 0 .
In the third test case, m=1⋅210=210 and has 16 divisors [1,2,3,5,6,7,10,14,15,21,30,35,42,70,105,210] . The 6×6 table with marked divisors is shown below:
1234561123456224681012336912151844812162024551015202530661218243036 Array a = [1,1,1,1,1,0,2,0,3,0,5,0,0,0,0,0] . There are 8 non-zero values, and xor of a is equal to 5 .