| Show all threads Hide all threads Show all messages Hide all messages |
| Why is this WA (#2)? | mbrc | 1120. Sum of Sequential Numbers | 7 May 2014 13:12 | 2 |
#include <cmath> #include <cstdio> #include <iostream> using namespace std; typedef long long LL; int main() { LL N,A,P,up; cin>>N; up=(LL)ceil((1.00+sqrt(1.00+8.00*(double)N))/2.00); P=up; while (((2*N)%P)!=0) { P--; }
A=(((2*N)/P)-P+1)/2;
cout<<A<<" "<<P<<endl; } This is my code...but this is giving WA on #2. I can't understand the reason. It seems to give correct answer on the tests I do on my computer..?!
At first sight, I strongly suggest you to avoid operating repeteadly with floating points, the little errors will accummulate, and WA comes to the order. at second sight the logic is just not right. Look, I got the same algorithm that a dude with TLE at test9, but with a less complex break condition. private static int sq(long A,long N){ double aux= Math.sqrt( ((A*A)<<2) - (A<<2) + 1 + 8*N); int r = (int)aux; if ((double)r==aux) return r; else return -1; } public static void main (String[]args){ Scanner s=new Scanner(System.in); int N= s.nextInt(); long A=1,P=1,root=0; while (true){ root= sq(A,N); if (root==-1) A++; else{ P= (1-(A<<1)+root)/2; break; } } System.out.println(A+" "+(P)); } |
| May program responds correctly. but why that's answered me Runtime error why? In JAVA 1.7 | Axmadjon | 1011. Conductors | 7 May 2014 12:05 | 1 |
import java.util.Scanner; public class _1011 { public static void main(String[] args) throws Exception { Scanner s = new Scanner(System.in); double p, q; p = Double.parseDouble(s.nextLine()); q = Double.parseDouble(s.nextLine()); p /= 100; q /= 100; answer(p, q, 1, 1, 0); } public static void answer(double p, double q, double m, double mp, long n) { long t = (long) (m / q) + 1; if (p * t < mp) { System.out.println(n + t); } else { answer(p, q, 1 - q * t + m, 1 - p * t + mp, n + t); } } } |
| please help me what Memory limit exceeded in test4 JAVA | Axmadjon | 1048. Superlong Sums | 7 May 2014 11:31 | 1 |
import java.util.Scanner; public class _1048 { public static void main(String[] args) throws Exception { Scanner s = new Scanner(System.in); int n, ind, i; n = s.nextInt(); int[] a = new int[n]; int[] b = new int[n]; int[] res = new int[n]; for (i = 0; i < n; i++) { a[i] = s.nextInt(); b[i] = s.nextInt(); } for (i = n - 1; i >= 1; i--) { ind = (a[i] + b[i]) / 10; if (ind > 0) { res[n - i] = ind; res[n - i - 1] += (a[i] + b[i]) % 10; } else res[n - 1 - i] += a[i] + b[i]; if (res[n - i - 1] >= 10) { res[n - i] += res[n - i - 1] / 10; res[n - i - 1] = res[n - i - 1] % 10; } } res[n - 1] += a[0] + b[0]; for (i = n - 1; i > -1; i--) System.out.print(res[i]); } } |
| Accepted in Java 1.7 | Axmadjon | 1021. Sacrament of the Sum | 7 May 2014 10:49 | 1 |
[delete] Edited by author 07.05.2014 10:53 Edited by author 07.05.2014 10:53 |
| please help me what Wrong answer in test 6 JAVA | Axmadjon | 1645. Ski Race | 7 May 2014 10:22 | 1 |
import java.util.Scanner; public class _1645 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int i, j; long n, min, max; n = s.nextInt(); long[] a = new long[(int) n]; for (i = 0; i < n; i++) { a[i] = s.nextInt(); } for (i = 0; i < n; i++) { min = 1; max = n; for (j = 0; j < n; j++) { if (j > i & (a[j] < a[i])) { min++; } if (j < i & (a[j] > a[i])) { max--; } } System.out.println(min + " " + max); } } } |
| The correct formula | lopezio | 1209. 1, 10, 100, 1000... | 6 May 2014 21:13 | 1 |
Here is the formula to find the 1 numbers: (sqr(n)+n+2)/2 n varies from 0 to .... |
| I have got a question concerning TASK 1209. Please help me if you can. | Kirill_1984 | 1209. 1, 10, 100, 1000... | 6 May 2014 19:59 | 1 |
Here is the code for the mentioned task. I use Dev-Pascal and when I run it on my computer there is no any problem, but when I send it to the server the following error occurs: "Runtime error (access violation)" MY CODE: program TASK_1209; var b, x, y: string; a: real; i, n, w, k: integer; begin x := '1' + x; for i:=1 to 10 do begin a := exp(ln(10) * i); str(trunc(a), b); x := x + b; end; readln(k); n := 0; repeat n := n + 1; readln(w); y := y + x[w] + ' '; until n = k; write(y); readln; end. |
| I have AC in Java 1.7 | Axmadjon | 1991. The battle near the swamp | 6 May 2014 19:09 | 1 |
|
| Wrong answer test 1 in Java 1.7 please help me | Axmadjon | 1506. Columns of Numbers | 6 May 2014 10:56 | 1 |
import java.util.Scanner; public class _1506 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n, k, j, i; n = s.nextInt(); k = s.nextInt(); k = (n + k - 1) / k; int[] a = new int[n]; for (i = 0; i < n; i++) { a[i] = s.nextInt(); } for (j = 0; j < k; System.out.println(""), j++) for (i = j; i < n; i += k) { System.out.print(" " + a[i]); } } } |
| To Who got Runtime Error | an phan | 1496. Spammer | 5 May 2014 15:55 | 1 |
First: When N is 0 exit the program and print nothing. Second: get attention in "range" of Array or vector (or what you use to save the team name) test 3: N = 0; test 5: N = any, but output is nothing. Hope it help you! |
| Hint | Bekzhan | 1298. Knight | 5 May 2014 11:39 | 2 |
Hint Bekzhan 23 Nov 2012 23:12 Backtracking works on this problem) I wrote code, using it, and i thought it'll got TL. But when I tried, it get AC) (Sorry for my poor english) The running time of a simple backtracking search will depend on the move search order you use. For example, this order: moves = [ a, e, f, b, c, g, h, d ] where a = (1,-2) b = (1,2) c = (-1,2) d = (-1,-2) e = (2,1) f = (2,-1) g = (-2,1) h = (-2,-1) works great for n = 7, but not 6 or 8. |
| It's strange. My prog runs faster when n=8 than when n=7. | Maigo Akisame (maigoakisame@yahoo.com.cn) | 1298. Knight | 5 May 2014 11:22 | 2 |
If you use a simple depth first search, your run time will depend on the order in which you examine the possible moves. For example, always examining the moves in this order yields a TLE: (1,2), (1,-2), (-1,2), (-1,-2), (2,1), (2,-1), (-2,1), (-2,-1). To get the fastest solutions you'll want to adapt the search order at each node in the search tree, but you can get an AC with a static search order. |
| Conjunctions can be empty strings apparently | Kuros | 1993. This cheeseburger you don't need | 4 May 2014 21:18 | 1 |
|
| there's always one common can | Zero | 1409. Two Gangsters | 4 May 2014 10:11 | 2 |
why output b-1 and a-1 you will get an AC? because there's always one common can in this way there are a+b-1 cans in total then Larry has a+b-1-a=b-1 cans left so does Harry the statement is very unclear.... |
| 1710 always WA at 26 | Tuz | 1710. Boris, You Are Wrong! | 3 May 2014 22:57 | 3 |
I have got WA at 26 several times. Is there something should i pay attention to ? Thank you. I had WA 26 when I used "cout << x...", but I've replaced it with "cout << setprecision(15) << x..." and it works. Edited by author 15.09.2009 23:17 if you check angle=pi/2, don't use scalar product. and setprecision(10) |
| How to get tests input | Volodymyr | | 3 May 2014 21:43 | 1 |
It seems it's impossible to get input of failed test on Timus Judge. I find it very bad. Moreover there isn't any feedback with Timus' owners. I mean I couldn't find any email or moderator address. Are you also consider that it'll be greate to attach test data to Wrong Answer results? |
| WA test 1 | Freddy | 1083. Factorials!!! | 3 May 2014 21:30 | 2 |
what's wrong with my code? i tried a few test cases and the result is good. #include<stdio.h> int main() { int num,n=0; int res=1; char a; scanf("%d ",&num); while(scanf("%c",&a)==1) n++; for(int i=num%n;i<=num;i+=n) { if(i==0) i=n; res=res*i; } printf("%d",res); } Edited by author 23.05.2013 23:39 try adding '\n' to the output |
| 37 Test | NotImplemented | 1382. Game with Cards | 3 May 2014 17:27 | 1 |
37 Test NotImplemented 3 May 2014 17:27 Can anybody provide me with 37 test? I have runtime error in Python. |
| deleted | Krasnov | 1995. Illegal spices | 3 May 2014 16:56 | 2 |
deleted Edited by author 26.10.2013 14:34 What is Test #6. Edited by author 11.10.2014 10:31 |
| Wrong answer in Java 1.7 test 4 please help me | Axmadjon | 1617. Flat Spots | 2 May 2014 19:33 | 1 |
import java.util.ArrayList; import java.util.Scanner; public class _1617 { public static void main(String[] args) throws Exception { Scanner s = new Scanner(System.in); ArrayList<Integer> list = new ArrayList<Integer>(); int n, i, count1 = 0, count2 = 0; n = s.nextInt(); int[] res = new int[n]; for (i = 0; i < n; i++) { res[i] = s.nextInt(); list.add(res[i]); } int e = 0; for (i = 0; i < list.size(); i++) { if (list.get(e).equals(res[i])) { count1++; if (count1 == 4) { count2++; } } } System.out.println(count2); } } |