|
|
back to boardRe: Test #14 When my program had WA14, I changed there: if(a - int(a) >= 0.5) to if(a - int(a) >= 0.5 + 1e-7) And I get AC!! Maybe it will help you! Good Luck!!! Edited by author 05.05.2007 16:50 Re: Test #14 Please, help WA 14. How can I change this? I think there is my mistake: pr_x >= pr_y and pr_y >= pr_x ----------------------------- double a = input.nextDouble(), b = input.nextDouble(); double pr_x = 0, pr_y = 0; int x = 0, y = 0, k = input.nextInt(); boolean yes; while (true) { pr_x = a - 2 * x - 1; pr_y = b - 2 * y - 1; yes = false; if (pr_x > 0 && pr_x >= pr_y && x + y + 1 <= k) { yes = true; x++; } else if (pr_y > 0 && pr_y >= pr_x && x + y + 1 <= k) { yes = true; y++; } if (!yes) { break; } } System.out.printf("%.2f\n%d %d\n", a * x + b * y - x * x - y * y, x, y); } Edited by author 30.01.2011 22:48 |
|
|