106 - Fermat vs. Pythagoras

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

Moderator: Board moderators

User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind » Tue Aug 07, 2007 3:24 am

you outputs are correct.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Tue Aug 07, 2007 7:32 pm

Use existing thread.
Ami ekhono shopno dekhi...
HomePage

ubernewb
New poster
Posts: 6
Joined: Mon May 01, 2006 8:26 pm

Post by ubernewb » Tue Aug 07, 2007 8:10 pm

I ran all the test cases in this thread, and they come out fine, but I'm still getting WA. Can someone help?

Code: Select all

Resolved
This is in C. If you have trouble compiling, try gcc -lm -o 106 106.c
Thanks
Last edited by ubernewb on Thu Aug 09, 2007 7:38 pm, edited 1 time in total.

mmonish
Experienced poster
Posts: 109
Joined: Sun Mar 11, 2007 2:55 pm
Location: SUST

Post by mmonish » Wed Aug 08, 2007 3:25 am

>>ubernewb
try this case

Code: Select all

Input
1000000
My AC Output
159139 133926
Hope this helps.

ubernewb
New poster
Posts: 6
Joined: Mon May 01, 2006 8:26 pm

Post by ubernewb » Wed Aug 08, 2007 6:19 pm

Tried that case, result came back OK. Here are the inputs I tried:
Input:

Code: Select all

10
11
12
15
20
22
50
55
80
100
500
600
700
800
900
1000
10000
100000
1000000
33221
33222
33333
33337
33339
33344
33354
33355
33356
33357
99960
99961
99962
99963
99964
99965
99966
99967
99968
99969
99970
99980
99990
99995
99999
100000
999991
999992
999993
999994
999995
999996
999997
999998
999999
Output:

Code: Select all

1 4
1 5
1 6
2 5
3 7
3 9
7 15
8 14
12 22
16 27
80 107
95 127
112 142
128 162
140 180
158 205
1593 1669
15919 14844
159139 133926
5287 5187
5287 5187
5303 5204
5307 5205
5307 5206
5307 5206
5309 5208
5309 5207
5309 5207
5309 5208
15909 14841
15910 14841
15910 14842
15910 14842
15910 14842
15912 14842
15912 14842
15912 14842
15912 14843
15912 14843
15912 14841
15916 14841
15919 14844
15919 14844
15919 14844
15919 14844
159137 133923
159137 133924
159137 133925
159137 133926
159137 133924
159137 133925
159139 133925
159139 133926
159139 133926
[/code]

User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind » Wed Aug 08, 2007 7:00 pm

My accepted code produces same output.

mmonish
Experienced poster
Posts: 109
Joined: Sun Mar 11, 2007 2:55 pm
Location: SUST

Post by mmonish » Thu Aug 09, 2007 3:47 am

>>ubernewb
I check ur code with this input & it produces the following output
159139 133059 which is not correct.
Did u make any change in ur code?
If not then check ur code again.

ubernewb
New poster
Posts: 6
Joined: Mon May 01, 2006 8:26 pm

Post by ubernewb » Thu Aug 09, 2007 6:16 pm

That's really weird. I ran it with 1000000 as input, and got 159139 133926. But you're saying that when you run it, it comes out with a different answer.
There must be something wrong in my code that makes it have different output on different compilers/machines, but I can't figure out what that is.

ubernewb
New poster
Posts: 6
Joined: Mon May 01, 2006 8:26 pm

Post by ubernewb » Thu Aug 09, 2007 6:26 pm

Accepted!
So, my problem was declaring that huge array locally in main. If instead I declare it globally, it works fine.
I'm guessing that the array can overflow main's stack, depending on your compiler/architecture/operating system. Thanks for all your help.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo » Thu Aug 09, 2007 6:31 pm

>> ubernewb
Remove your code plz..~ :-)

imrankane2005
New poster
Posts: 4
Joined: Mon Aug 13, 2007 3:12 pm

106 Time Limit Exceeded (Fermat vs Pythagorean)

Post by imrankane2005 » Thu Aug 16, 2007 3:13 pm

wat is wrong with compiler.
when i m submitin a wrong answer code wich eval. max. no. 1000000 in less then 3 sec in my computer. It Gives Time limit exceeded instead of WA..
also gives Time Limit Exceeded for the correct sol. when i submits it.
this eval. a max of around 9 sec for 1000000.

i hav used while(cin>>max) in my code
is this wrong...
also
wat is mean by 'Input is terminated by end-of-file' statement given in probl.

If any One asks for my code i can giv him....

Ron
Learning poster
Posts: 55
Joined: Mon Jul 23, 2007 5:01 pm
Location: INDIA

Post by Ron » Thu Aug 16, 2007 6:43 pm

You are going on wrong way. Time Limit Exceed is not for a single input. It's for total input cases in judge's input file. In your code, you are measuring for a single maximum input.
Check your code with given input cases in

http://acm.uva.es/board/viewtopic.php?t ... 2296d9d630

You should change your algorithm...
With Best Regards
Surendra Meena

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Thu Aug 16, 2007 7:10 pm

Dont open a new thread if there is one already.
Ami ekhono shopno dekhi...
HomePage

riyad_csedu
New poster
Posts: 3
Joined: Sun Aug 27, 2006 5:40 pm
Location: Dhaka
Contact:

why compilation error? plz help!

Post by riyad_csedu » Mon Dec 03, 2007 10:43 am

Code: Select all

/* compile error, Help plz */
Deleted after AC
Last edited by riyad_csedu on Mon Dec 03, 2007 8:09 pm, edited 1 time in total.

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

not not

Post by sohel » Mon Dec 03, 2007 11:16 am

You can't use not as a variable name.

Post Reply

Return to “Volume 1 (100-199)”