11245 - Anti-Arithmetic-Sequence

All about problems in Volume 112. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

11245 - Anti-Arithmetic-Sequence

Post by Wei-Ming Chen »

I am wondering why wrong answer, can someone check the I/O below?

Input:

Code: Select all

9
5 18
10000 3
100000 3
45214522 9
2000000000 15
111111111 7
417748545 13
10202010 27
2000000000 3
My output

Code: Select all

5
1679657
57476669
112354598
3400966932
484878943
728021160
11857697
301084278403433
Or some stricky I/O? Thanks

Edit: The outputs are correct, but becare of that n might > 2*10^9
Last edited by Wei-Ming Chen on Sun Jul 29, 2007 9:00 am, edited 1 time in total.
pvncad
New poster
Posts: 27
Joined: Sun Feb 18, 2007 2:14 pm

Post by pvncad »

hi,

For p = 5, i think, sequence should look like

1, 2, 3, 4, 8, 9, 10, 11, 22, 23, 24, 25, 29, ....

But from sample test, answer of n = 10, p = 5 is 12. Am I missing something here ?
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

for p=5

sequence will be
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, ....
pvncad
New poster
Posts: 27
Joined: Sun Feb 18, 2007 2:14 pm

Post by pvncad »

thanks. Now, I know what I missed out.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Post by Wei-Ming Chen »

yes... it really help

I got Acceped now..

but why... the problem say n<=2000000000...
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

Wei-Ming Chen wrote: but why... the problem say n<=2000000000...
What is the problem with that?
Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Post by Wei-Ming Chen »

Oh, I mean that it say
Each case contains 2 integers n (1≤n≤2*10^9) and p (3≤p≤30)
in the problem B (11245)
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

I still can't figure out the case when p is not prime.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

There is not any case in judge's input where p is not prime.
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

shouldn't they say that somewhere in the problem statement? I spent quite a long time on it.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

Really, it troubles!!!
sonyckson
New poster
Posts: 49
Joined: Tue Feb 06, 2007 9:29 pm
Location: Cordoba, Argentina

Post by sonyckson »

Hello... i have found a kind of pattern and solved the problem... but i would like to know why my solution function... can anyone give some hints to think about?
I dont give the pattern but i suppose the majority have done it in this way... Thanks ! eric.
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

sonyckson wrote:Hello... i have found a kind of pattern and solved the problem... but i would like to know why my solution function... can anyone give some hints to think about?
I dont give the pattern but i suppose the majority have done it in this way... Thanks ! eric.
Did you solve the case for p not prime?

If p is prime, then a number theory proof works. It would be a spoiler if I post complete proof here. The key ingredient in the proof is the requirement for gcd(x,p)=1 for any x.

The proof was actually used in the solution of a USAMO 95 problem before.
It was not supposed to be very obvious, but to anyone used to olympiad problems, this should've been easy.
http://www.kalva.demon.co.uk/usa/usoln/usol951.html
Post Reply

Return to “Volume 112 (11200-11299)”