[gcj] Re: Code Jam 2019 Round 1C Power Arrangers problem gives me WA. Please help.

2019-05-04 Thread john.smith
Nearly right. Instead of scanf("%c",&c) put a space in the " %c". The space makes the scanf match zero or more white space characters, which will consume stray end-of-line characters. In the final char str[5]={r1,r2,r3,r4,r5}; //cout

[gcj] Re: CODE ERROR-thank you in advance

2019-04-15 Thread john.smith
What answer do you get for test case 1 48 I think your code reverses the digits of 48 to get 84, then reverses back again, swapping digit 4 for 1, and other digits to 0, resulting in value 10. But "479000 10" is not a valid answer. -- You received this message because you are subscribe

[gcj] Re: Forgone Solution Causing Problem in only Codejam test scenario

2019-04-13 Thread john.smith
Another failure case is 144491 After uncommenting your line print("After operation a,b",a,b) I see After operation a,b 10 51 After operation a,b 144389 102 After operation a,b 143888 603 After operation a,b 138887 5604 After operation a,b -361114 505605 Case #1: -361114 505605 -- You re

[gcj] Re: Can I expect any help from this community at all?

2019-04-12 Thread john.smith
There are some things you could try: 1. Post some test cases you have used. 2. Avoid posting code with multiple blank lines (individual blank lines can be good to improve readability) 3. Avoid variable names consisting of just a lower case "L" - they are hard to read 4. Remove unused variables. 5

[gcj] Re: Cubic UFO - Why did my code fail the test case 2?

2018-04-15 Thread john.smith
On Friday, April 13, 2018 at 2:36:19 AM UTC+1, Yupeng Gu wrote: > from math import sqrt,pi,sin,cos > tt = int(raw_input()) > > _mid = sqrt(2.0) > > def findRad(lower,upper,target,func): > if upper-lower<0.0001: > return upper > mid = (upper+lower)/2.0 > if func

[gcj] Re: Algorithm for filling water

2016-04-26 Thread john.smith
It is an old question. I met it in a computer science class in 1983/4, where I think it had previously been an exam question. The discussion in class went round in circles considering various recursive approaches. I think we missed main idea. Or perhaps I just didn't understand at the time. Th

[gcj] Re: Can anybody post the analysis of Sqaure Field problem from 2008 practice contest.

2015-05-09 Thread john.smith
I tried coding LeppyR64's dynamic programming method. If end up with nested loops loop r=2...k for all subsets S of {1...n} for all subsets T of S best cover S with r squares = min(max(cover T with 1 square, cover S-T with r-1 squares) Alternatively, do a binary se

[gcj] Round 1A Problem C Logging: The size of eps

2015-04-19 Thread john.smith
I was largely defeated by this problem. I hacked an awful convex-hull algorithm, and brute-forced a solution to the small test case. I was interested to look at some of the solutions by the best. Many of the successful solutions calculate angles between trees using floating point arithmetic exp

Re: [gcj] Re: Big Integer Libraries

2013-05-02 Thread john.smith
On Wednesday, May 1, 2013 9:08:12 PM UTC+1, Vaibhav Tulsyan wrote: > 1. Are you using 'mpz_class' as a generalisation of all classes of the gmp > library? I'm asking because in the tutorial they've used mpz_t. Will that > factorial code work if I use mpz_t as the return type instead of mpz_class?

[gcj] Re: Big Integer Libraries

2013-05-01 Thread john.smith
The tutorial doesn't really tell you how wonderfully easy it is to use gmp in c++. If you want a factorial function, say: mpz_class fact(unsigned int n) { if (n==0) return 1; return n*fact(n-1); } If you want to print a big factorial number, cout << fact(40); Most of the time you

Re: [gcj] Re: 1A-Prob 2. ManageYourEnergy

2013-04-29 Thread john.smith
I didn't think of it at the time, but a greedy divide and conquer algorithm works. Initial energy is E, and the best strategy has final energy 0. But solve a more general problem with other given values of initial and final energy. The algorithm is to choose the task of greatest value. Determin

[gcj] Re: On the way to programming .

2011-08-07 Thread john.smith
Google codejam questions do not need much knowledge, but they do need very crisp thinking, and an ability to write correct code quickly. Debugging solutions during a code-jam round is very stressful, and best avoided by getting the code right first time. Practice on the past Google code-jam proble

[gcj] Re: Goro sort again

2011-05-10 Thread john.smith
On May 10, 5:56 am, Bartholomew Furrow wrote: > > It says Goro is sorting N integers, but not that the integers are > > 1...N.  Are the GCJ question setters being kind by only using arrays > > of 1...N in their test cases? > > """The second line of each test case will contain a permutation of the

[gcj] Goro sort again

2011-05-09 Thread john.smith
A few thoughts: It says Goro is sorting N integers, but not that the integers are 1...N. Are the GCJ question setters being kind by only using arrays of 1...N in their test cases? It says Goro wants to sort the integers, but doesn't require the sorted order to be increasing. How would the answer