Hey everybody,
Wellcome to Codeforces Beta Round #24. I'm author to most of the problems today. Something about me: My name is Nedyalko Prisadnikov and I'm a student from Sofia University in Bulgaria. Here are some pictures of me. Many thanks to Mike Myrzayanov and to Artem Rakhov for organizing the contest, writing alternative solutions and some of the problems.
Good luck and have fun!
UPD:
Wellcome to Codeforces Beta Round #24. I'm author to most of the problems today. Something about me: My name is Nedyalko Prisadnikov and I'm a student from Sofia University in Bulgaria. Here are some pictures of me. Many thanks to Mike Myrzayanov and to Artem Rakhov for organizing the contest, writing alternative solutions and some of the problems.
Good luck and have fun!
UPD:
/*
long long id;
int n;
scanf("%d %lld",&n, &id);
*/
and got wrong answer on test 3, but when i changed to Ms C++ with the same code, i got yes. Can anyone tell me the reason ? can not i use %lld in GNU C++ ?
To speed it up notice that the first ⌊ j / n⌋ "cycles" can be processed faster with a sort of parity trick. In particular, any even number of cycles can be dismissed and the rest can be processed with the naive algorithm.