B. z-sort 题目连接: http://www.codeforces.com/contest/652/problem/B Description A student of z-school found a kind of sorting called z-sort. The array a with n elements are z-sorted if two conditions hold: ai ≥ ai - 1 for all even i, ai ≤ ai - 1 for all…
Codeforces Round #384 (Div. 2) 题目链接:Vladik and fractions Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer \(n\) he can represent fraction \(\frac{2}{n}\) as a sum of three distinct posi…
Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is cal…
题目链接: C. Foe Pairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a permutation p of length n. Also you are given m foe pairs (ai, bi) (1 ≤ ai, bi ≤ n, ai ≠ bi). Your task…
Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. Input The only line contains odd integer n (1 ≤ n ≤ 49). Output Print n lines with n integers. All the integers should be differ…
题目描述: High Load time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of…
You are given a prime number pp, nn integers a1,a2,…,ana1,a2,…,an, and an integer kk. Find the number of pairs of indexes (i,j)(i,j) (1≤i<j≤n1≤i<j≤n) for which (ai+aj)(a2i+a2j)≡kmodp(ai+aj)(ai2+aj2)≡kmodp. Input The first line contains integers n,p,…
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal. Greatest common divisor of sequence is maximum of…