题意:给你n*n gcd表中的所有数(以任意顺序) ,求对角线上的n个数分别是什么.gcd表定义如下,先将n个数填在对角线的上,然后将各个格子填上对应对角线上的数的gcd值,也就是V[i][j]=gcd(V[i][i],V[j][j]) 题解:观察发现有很多重复的数,而且最大的那个数必然是对角线上的数.所以用map存数据,map.first 存数,map.second存次数. 一开始发现了如果最大的数N重复x*x次,那么对角线上就有x个N,于是每次输出根号次最大的数,用这个规律wa23了(233…
题目链接:http://codeforces.com/contest/583/problem/C C. GCD Table time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The GCD table G of size n × n for an array of positive integers a of length n …
题目链接:http://codeforces.com/problemset/problem/582/A 网上很多题解,就不说了,直接贴代码= = 官方题解: http://codeforces.com/blog/entry/20692 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include &…
主题链接:点击打开链接 特定n*m矩阵,[i,j]分值为gcd(i,j) 给定一个k长的序列,问能否匹配上 矩阵的某一行的连续k个元素 思路: 我们要求出一个解(i,j) 使得 i<=n && j<=m 此时输出 YES 对于j j % b[0] = 0 j+1 % b[1] = 0 ··· j+l % b[l] = 0 依据定理:若 a == b (mod n) => (a+c) == b+c (mod n) 所以将上式变换为 j % b[0] = 0 j % b[1]…
什么都不会只能学数论QAQ 英文原题不贴了 题意: 有一张N*M的表格,i行j列的元素是gcd(i,j)读入一个长度为k,元素大小不超过10^12的序列a[1..k],问这个序列是否在表格的某一行中出现过 1<=N,M<=10^121<=k<=10^4 恩 首先显然x=lcm(a[i]) 然后(y+i-1)%a[i]==0 即y%[i]=1-n 然后就神奇地变成了中国剩余定理 求出x和y后判无解即可,情况比较多 首先如果x和y超过n,m的范围或<0显然不对 然后注意枚举i看g…
题意简述: 给定一个长度为$n$的序列 将这个序列里的数两两求$gcd$得到$n^2$个数 将这$n^2$个数打乱顺序给出 求原序列的一种可能的情况 ----------------------------------------------------------------------------------------------------------------------- 比赛时一直去想有什么特殊的性质(找规律) 比如这些数里为一个数的倍数的数一定是平方个 然而按照这样的思路去想又…
C. GCD Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/583/problem/C Description The GCD table G of size n × n for an array of positive integers a of length n is defined by formula Let us remind you that the greatest c…
C. GCD Table The GCD table G of size n × n for an array of positive integers a of length n is defined by formula Let us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both…
A. GCD Table time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The GCD table G of size n × n for an array of positive integers a of length n is defined by formula Let us remind you that the…
4491. Primes in GCD Table Problem code: PGCD Johnny has created a table which encodes the results of some operation -- a function of two arguments. But instead of a boring multiplication table of the sort you learn by heart at prep-school, he has cre…