Show all threads Hide all threads Show all messages Hide all messages |
в компиляторе работает, а тут runtime error | Radian | | 15 Mar 2016 15:00 | 2 |
В компиляторе работает а тут пишет ошибку. import java.util.*; import java.math.*; import java.io.*; public class koren { public static void main(String[] args) {
Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int d = in.nextInt();
System.out.format("%.4f%n", Math.sqrt (a)); System.out.format("%.4f%n", Math.sqrt (b)); System.out.format("%.4f%n", Math.sqrt (c)); System.out.format("%.4f%n", Math.sqrt (d));
} } Edited by author 15.03.2016 05:59 Good people don't want other people to guess. Good people show task number and type of error and test number - is it definitely "run-time error"? I guess it is "1001 reverse root". In this case you MUST read and understand task. Does task say you have 4 and only 4 integers to read? Task says you have unknown number of 64 bit longs to read. Task also says you should write output in reverse order. Also I think you haven't check task sample locally. Your program should fail during reading "876652098643267843" as 32 bit int. |
WA #2. Still everything is right. \\// Ошибка в тесте №2. Хотя всё и так правильно | Batyr Nuryyev | 1197. Lonesome Knight | 14 Mar 2016 23:36 | 1 |
Here it is. \\ // Вот код. #include <iostream> using namespace std; int main() { int n; cin >> n; int arrint[n]; char arrchar[n]; for (int i = 0; i < n; i++) { cin >> arrchar[i] >> arrint[i]; if ((int(arrchar[i]>104)) || (int(arrchar[i]) < 97)) break; if ((arrint[i] < 1) || (arrint[i] > 8)) break; } for (int i = 0; i < n; i++) { if ((int(arrchar[i]) >= 99) && int(arrchar[i]) <= 102) { if ((arrint[i] >= 3) && (arrint[i] <= 6)) { cout << "8" << endl; } else if ((arrint[i] == 2) || (arrint[i] == 7)) { cout << "6" << endl; } else { cout << "4" << endl; } } else if ((int(arrchar[i] == 98)) || (int(arrchar[i] == 103))) { if (((arrint[i]) >= 3) && (arrint[i] <= 6)) { cout << "6" << endl; } else if ((arrint[i] == 2) || (arrint[i] == 7)) { cout << "4" << endl; } else { cout << "2" << endl; } } else { if (((arrint[i]) >= 3) && (arrint[i] <= 6)) { cout << "4" << endl; } else if (((arrint[i]) == 2) || (arrint[i] == 7)) { cout << "3" << endl; } else { cout << "2" << endl; } } } return 0; } |
ошибка: Runtime error (access violation), подскажите как исправить? С++ | Krychun Ivan | 1001. Reverse Root | 14 Mar 2016 21:11 | 2 |
#include <stdio.h> #include <tchar.h> #include <math.h> int charToNumber(char charValue) { if (charValue >= '0' && charValue <= '9') { return charValue - '0'; } } int main() { int CountOfAllNumbers = 1; int CountOfNumbers = 0; bool flag = 0; double *numbers = new double[4]; numbers[CountOfAllNumbers] = 0; char *A = new char [100]; scanf("%s", &A); for (int i = strlen(A)-1; i >= 0; i--) { if (((A[i] == ' ') || (A[i] == '\t'))|| (A[i] == '\n')) { CountOfNumbers = 0; if (flag) { CountOfAllNumbers++; numbers[CountOfAllNumbers] = 0; flag = 0; } } else { flag = 1; numbers[CountOfAllNumbers] = numbers[CountOfAllNumbers] + charToNumber(A[i])*pow(10.0, CountOfNumbers); CountOfNumbers++; } } for (int i = 1; i < CountOfAllNumbers; i++) { printf("%lf\n", sqrt(numbers[i])); } delete[] numbers; return 0; } Edited by author 14.03.2016 16:28 You are trying to read WHOLE input in one read, into 100 bytes buffer. But input is up to 256Kb; scanf "%s" reads non-white-space data and stops on the first white-space. You expect not more then 4 numbers. There are up to 256K/2 numbers. You should better use scanf "%lld" / scanf "%lf" in the cycle. You should allocate big enough "numbers" array (or use std::vector). You also should run locally at least test in the task sample and receive EXACTLY the sample output. |
whats wrong!!!!! Everything is right | shubham | 1293. Eniya | 14 Mar 2016 05:42 | 4 |
#include<stdio.h> main() { int n, a, b; int weight; while (scanf("%d", n) != EOF || scanf("%d", a) != EOF || scanf("%d",b) != EOF) { weight = n*a*b * 2; printf("%d", weight); } return 0; } 1. You should specify the return type value for the main function: int main() {} 2. Is not necessarry to read the input data until the end of stream. Just read it one time: int n, a, b, w; scanf("%d%d%d", &n, &a, &b); w = n*a*b*2; printf("%d\n", w); Please read scanf documentation. It returns count of read variables. Also - task description means 3 and only 3 integers to read. Why did you use "while" here? The main problem is in "||". You should use "&&" anyway. Otherwise, the shortpath magic happens. |
Runtime error in test 12 | Gorbatykh Michail | 1453. Queen | 14 Mar 2016 02:14 | 1 |
I don't understand, where I made a mistake, but program crushes there everytime, although in my compilator it is works Edited by author 15.03.2016 01:56 |
test case 3 | zahra | 1454. Rectangles 2 | 14 Mar 2016 01:30 | 1 |
judje saied my solution does not work correctly on #3 and i do not know what is #3 but i think my code works correctly |
here is a solvation | Costel::icerapper@k.ro | 1100. Final Standings | 13 Mar 2016 23:30 | 9 |
program timus_1100; const maxn=150000; var ID:array[1..maxn]of longint; np:array[1..maxn]of byte; n:longint; i,j:longint; begin readln(n); for i:=1 to n do readln(ID[i],np[i]); for i:=100 downto 0 do for j:=1 to n do if np[j]=i then writeln(ID[j],' ',np[j]); end. the difficulty is too high! > program timus_1100; > const > maxn=150000; > var > ID:array[1..maxn]of longint; > np:array[1..maxn]of byte; > n:longint; > i,j:longint; > begin > readln(n); > for i:=1 to n do > readln(ID[i],np[i]); > for i:=100 downto 0 do > for j:=1 to n do > if np[j]=i then > writeln(ID[j],' ',np[j]); > end. > i used this way and i've got wrong answer it third test. maxn=150000; why 15000???? you have only 100!!!! |
Java 1.8 Program Works fine in console and eclipse but gives wrong answer | Sohan Agate | 1001. Reverse Root | 13 Mar 2016 00:34 | 1 |
Program is in Java 1.8 but gives wrong answer on the timus server. Any help will be appreciated. Thanks a lot. import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class ReverseRoot { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); List<Long> list = new ArrayList<Long>(); while ( in.hasNextLong() ) { long l = in.nextLong(); list.add(l); } DecimalFormatSymbols s = new DecimalFormatSymbols(); s.setDecimalSeparator('.'); DecimalFormat df = new DecimalFormat("#,####0.0000",s); for (int i = list.size() - 1; i >= 0; --i) { out.println(df.format(Math.sqrt(list.get(i)))); out.flush(); }
} } |
Why wrong?????????????? | IT | 1617. Flat Spots | 12 Mar 2016 20:21 | 1 |
var A:array[1..1000] of integer; i,s,n,b,r,m,j,k,d,q:integer; begin s:=0; r:=0; q:=0; read(n); for i:=1 to n do readln(A[i]); begin for i := 1 to n-1 do for j := 1 to n-i do if A[j] > A[j+1] then begin k := A[j]; A[j] := A[j+1]; A[j+1] := k end; end; for i:=1 to (n-1) do begin d:=i+q; if (A[d]=A[d+1]) then s:=s+1 else s:=0; if s=3 then begin r:=r+1; s:=0; q:=1+q; end; end; write(r); end. |
What is trickly test 2? | Strekalovsky Oleg [Vologda SPU #1] | 1876. Centipede's Morning | 12 Mar 2016 19:32 | 11 |
no,need 39*2 + 40 + 60 * 2 + 1 This problem don't need more than 3 tests, I think ;) Edited by author 22.10.2011 20:08 NO, I think this problem don't need more than 2 tests. there are 2 possible answers: 2*a+39 and 2*b+40. you must choose biggest Why 39 ????? What is 2*a+39 ????? Why 39 ????? What is 2*a+39 ????? 39 * 2 + 40 + (a - 40) * 2 + 1 = 2 * a + 39 |
I understand myself. Here is explaining | IlushaMax | 1225. Flags | 12 Mar 2016 16:59 | 1 |
Let W is WHITE, R is RED, B is BLUE So for n=1: f(n)=2 W or R; for n=2: f(n)=2 too WR or RW; And now the most interesting: for n=3: f(n)= We add to combinations of n-1 W or R: WRW or RWR; + We add to combinations of n-2 RB or WB: RBW or WBR; =f(n-1)+f(n-2); So you can check it for n=4 and n=5///It's really easy |
HELP! merge_sort gets WA#5 ,who can give me some test cases,please? | Fighting | 1090. In the Army Now | 12 Mar 2016 14:12 | 2 |
|
text 9 Runtime error (access violation) | Emily Huo | 1001. Reverse Root | 9 Mar 2016 17:14 | 2 |
#include <stdio.h> #include <math.h> #define N 100000 int main(){ double n; double line[N]; int i = 0 ;
while(scanf("%lf",&n) != EOF) { line[i++] = n; } while(i-- > 1) { printf("%0.4lf\n",sqrt(line[i])); } printf("%0.4lf",sqrt(line[i])); return 0; } > #define N 100000 Why do you think 100,000 is enough? Why do you place so big arrays on stack? You should better use std::vector or dynamic allocation. Why do you have 2 equal "printf" lines? You should better change "while" condition. |
PLEASE HELP!!! WA #3 | kami_botanik | 1002. Phone Numbers | 9 Mar 2016 15:29 | 1 |
I tried all tests given from kind people in forum and also I tried my own different tests. I have passed in all of it, but I got Wrong Anser 3. Can anybody help me with some tests or someting else?... Please be kind ((( |
Why on FPS There isn't any compilation errors but when i'm trying to send it then compilation error | IlushaMax | 2023. Donald is a postman | 9 Mar 2016 02:33 | 1 |
Edited by author 09.03.2016 02:44 |
Test 6. What's wrong? pascal | Nick | 1787. Turn for MEGA | 8 Mar 2016 20:23 | 1 |
var minutes, carsAtMin, stay, i: byte; countOfCars: array[0..100] of integer; BEGIN readln(carsAtMin, minutes); stay := 0; for i:=1 to minutes do readln(countOfCars[i]); for i:=1 to minutes do begin countOfCars[i] := countOfCars[i] + stay; stay := 0; if (countOfCars[i] - carsAtMin > 0) then stay := countOfCars[i] - carsAtmin; end; if (stay > 0) then write(stay) else write('0'); END. |
HINT | IlushaMax | 1924. Four Imps | 8 Mar 2016 16:19 | 1 |
HINT IlushaMax 8 Mar 2016 16:19 Use properties of arithmetic progression |
time limit exceeded | IT | 1880. Psych Up's Eigenvalues | 8 Mar 2016 15:02 | 2 |
var A:array[1..4000] of integer; B:array[1..4000] of integer; C:array[1..4000] of integer; q,w,e,r,t,y,i,o,p,s:integer; begin read(q); for r:=1 to q do read(A[r]); read(w); for t:=1 to w do read(B[t]); read(e); for y:=1 to e do read(C[y]); for i:=1 to q do begin for o:=1 to w do for p:=1 to e do if (A[i]=B[o]) and (A[i]=C[p]) then inc(s); end; write(s); end. You should make variables like i1 ,i2, i3 but not q,w,e.r,t,y you know? So your program isn't clear. And about your timelimi.... : put here for o:=1 to w do >>> for p:=1 to e do if (A[i]=B[o]) and (A[i]=C[p]) then inc(s); this: if A[i]=B[o] then begin for p:=1 to e do if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);end; and...think about what you can delete from this: if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);end; |
Pascal and binary operations | Demenev Dmitriy | 1877. Bicycle Codes | 7 Mar 2016 19:55 | 4 |
I used binary operations to solve the problem and I didn't manage make my algorithm faster. My algorithm is too slow (0.015 sec). Could you give me a little advice how I can optimise my algorithm? My facebook: https://www.facebook.com/dmitriy.demenev.7Time is rounded here, so you can only see results like 0.001, 0.015, 0.031, 0.046, 0.062 etc. 0.001 and 0.015 are pretty much equal, and 0.015 can mean pretty much anything between 0.002 and 0.015. Like 0.001, 0.015 is an ideal time, there's nothing to optimize here. Only starting from 0.031 the program might be considered "slightly slow". Thank you, Jane. It was really important for me. I got crazy of this runtime. It was like a bolt out of the blue xD Good luck!. Btw, sorry for my English :D |
Help me, please! Pascal... | KOTMAKRUS | 1293. Eniya | 7 Mar 2016 18:44 | 3 |
program en; var a,b,c:byte; BEGIN read(a,b,c); write(b*c*2*5); END. Where my mistake? Test 2 - Wrong Answer... I am stupid.....)) write(b*c*2*a); ..... for 0.001 sec write(a*b*c+a*b*c) |