a. counterexample
time limit per test 1 second
memory limit per test 256 megabytes
your friend has recently learned about coprime numbers. a pair of numbers {a,?b} is called coprime if the maximum number that divides both a and b is equal to one.
your friend often comes up with different statements. he has recently supposed that if the pair (a,?b) is coprime and the pair (b,?c) is coprime, then the pair (a,?c) is coprime.
you want to find a counterexample for your friend's statement. therefore, your task is to find three distinct numbers (a,?b,?c), for which the statement is false, and the numbers meet the condition l?≤?a?
more specifically, you need to find three numbers (a,?b,?c), such that l?≤?a?l>>r) { int vis = 0; for(ll a = l; a
b. friends and presents
time limit per test 1 second
memory limit per test 256 megabytes
you have two friends. you want to present each of them several positive integers. you want to present cnt1 numbers to the first friend and cnt2 numbers to the second friend. moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
in addition, the first friend does not like the numbers that are divisible without remainder by prime number x. the second one does not like the numbers that are divisible without remainder by prime number y. of course, you're not going to present your friends numbers they don't like.
your task is to find such minimum number v, that you can form presents using numbers from a set 1,?2,?...,?v. of course you may choose not to present some numbers at all.
a positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.
input
the only line contains four positive integers cnt1, cnt2, x, y (1?≤?cnt1,?cnt2?109; cnt1?+?cnt2?≤?109; 2?≤?x? v - c1 || v / y > v - c2) return false; if(v - c1 - c2 >c1>>c2>>x>>y) { ll l = 1; ll r = 1e9* 2; while(l > 1; if(check(mid)) r = mid; else l = mid + 1; } cout
c. diverse permutation
time limit per test 1 second
memory limit per test 256 megabytes
permutation p is an ordered set of integers p1,?p2,?...,?pn, consisting of n distinct positive integers not larger than n. we'll denote as n the length of permutation p1,?p2,?...,?pn.
your task is to find such permutation p of length n, that the group of numbers |p1?-?p2|,?|p2?-?p3|,?...,?|pn?-?1?-?pn| has exactly k distinct elements.
input
the single line of the input contains two space-separated positive integers n, k (1?≤?k?>n>>k; int a = 1,b = n; while(a = 0; i--) printf(i == 0? %d\n : %d ,t[i]); else for(int i = 0; i