Общий форумПоказать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | Почему результат "Runtime error"? чем ему Reader не понравился? | Алексей | 1000. A+B Problem | 28 окт 2015 13:23 | 4 | import java.io.*; import java.util.*; public class A_B_Problem { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int A = Integer.parseInt(reader.readLine()), B = Integer.parseInt(reader.readLine()); out.println(A + B); out.flush(); } } BufferedReader faster, and consumes less memory, what is the problem? See the input format carefully Andrew Sboev "Numbers are located at the same line. So, first call of readLine() give you "a b", and second - null." Потому что по условию задачи входные данные должны быть вида - "5 _ 1", а, если пользуешься ReadLine - то у тебя будет так, 5 1 а ввод вида "5 1" возможен при помощи сканнера Edited by author 28.10.2015 13:28 | Problem 1012. K-based Numbers, Version 2 was changed | Vladimir Yakovlev (USU) | 1012. K-ичные числа. Версия 2 | 28 окт 2015 06:09 | 3 | The limitations were changed from 180 to 1800. But why the problem was rejudged without any announcement? I get WA1 now (looks like due to compiler) but haven't received any e-mail 'bout this. And I don't think this is a good idea to rejudge solutions sent 10+ years ago - personally I don't like to refresh my old (bydlo-)sources on old languages to fit them to new compilers. I think, you have forgotten to change the limits on k. Now it can be more than 10. | Please, give me some test!!! | Algorithmus_UA(algorithmus@univ.kiev.ua) | 1110. Степень | 27 окт 2015 21:20 | 7 | I take WR!!! I don't know what s wrong!!! ---------------------------------MY PROGRAM------------------------- var N,M,Y:longint; a:array[1..15]of byte; b:array[1..15]of longint; d:array[1..1000]of integer; h,x,l:integer; i,j,s:longint; begin assign(input,'1110.dat'); reset(input); readln(N,M,Y); x:=N; for i:=1 to 15 do begin a[i]:=x mod 2; x:=x div 2; if x = 0 then break; end; l:=i; for i:=0 to M-1 do begin b[1]:=i; for j:=2 to l do begin b[j]:=(b[j-1]*b[j-1]) mod M; end; s:=1; for j:=1 to l do if a[j]=1 then begin s:=(s*b[j]) mod M; end; if s = Y then begin inc(h); d[h]:=i; end; end; for i:=1 to h-1 do write(d[i],' '); if h<>0 then writeln(d[h]); end. The answer for test 1 2 3 Should be -1 GL > The answer for test > 1 2 3 > Should be > -1 > > GL 0 0 0 _______ Answer: 0 No, because X in the interval [0, M − 1] I think answer is -1 Since, (0 < N < 999, 1 < M < 999, 0 < Y < 999) the minimum input is: 1 2 1 with the answer 1 Megakrit, This is best test! Thank you! Edited by author 27.10.2015 21:21 | 1001. Runtime error. Java | Java.Xotatel | 1001. Обратный корень | 27 окт 2015 21:01 | 2 | Good afternoon, tell me please, what is wrong with the code? In Eclipse, I have everything working. Maybe I misunderstood condition. I wrote so that the program first asks how many numbers will be introduced, and then takes them. ------------------------------------------- import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.*; public class zadacha { public static void main(String[] args) { System.out.println("Сколько чисел вы хотите ввести?"); Scanner scan = new Scanner(System.in); int temp = scan.nextInt(); int arr[] = new int[temp]; for (int i=0; i < temp; ++i){ System.out.println("Введите число номер " +(i+1)); arr[i] = scan.nextInt(); } scan.close(); DecimalFormatSymbols s = new DecimalFormatSymbols(); s.setDecimalSeparator('.'); DecimalFormat f = new DecimalFormat("#,##0.0000", s); for (int j = temp-1; j >= 0; j--){ double z = Math.sqrt(arr[j]); System.out.println(f.format(z)); } } } Remove all outputs which are not connected with the task. | Time limit exceeded | Daniil | 1118. Нетривиальные числа | 27 окт 2015 09:15 | 3 | Подскажите, как сократить время работы программы? [code deleted] Edited by moderator 19.11.2019 23:42 First you should rewrite function which counts sum of divisors: for (i=2;i*i<=n;i++)..., second you shouldn't compute triviality of all numbers in [i,j]: just for numbers from j downto first prime number>=i, and of course take into account that triviality(1)=0. | To all LAMERS!!! | Yuriy Frolov (ufrolov@ukr.net) | 1017. Лестницы | 27 окт 2015 04:49 | 14 | const n=500; var a:array[1..n]of string; i,j,k,l,m,rk,v,t,z,pus:longint; sum,ss,zz:string; function mmm(p:longint):longint; begin v:=1; while ((v+1)*(v+2)) div 2<=p do v:=v+1; mmm:=v; end; function plus(pluss1,pluss2:string):string; {only pozitive!!!} var plusi,pluscode,plusi1,plusi2,plusna,plusba:integer; pluss,plusss:string; begin if pluss1='' then pluss1:='0'; if pluss2='' then pluss2:='0'; pluss:=''; while length(pluss1)<length(pluss2) do pluss1:='0'+pluss1; while length(pluss2)<length(pluss1) do pluss2:='0'+pluss2; plusna:=0; plusba:=0; for plusi:=length(pluss1) downto 1 do begin val(pluss1[plusi],plusi1,pluscode); val(pluss2[plusi],plusi2,pluscode); plusba:=(plusi1+plusi2+plusna) mod 10; plusna:=(plusi1+plusi2+plusna) div 10; str(plusba,plusss); pluss:=plusss+pluss; end; if plusna<>0 then begin str(plusna,plusss); pluss:=plusss+pluss; end; plus:=pluss; end; begin readln(m); for i:=1 to m do a[i]:='1'; sum:='0'; rk:=mmm(m); for i:=2 to rk do begin {ЇҐаҐЎ®а Ї® k} for j:=1 to i do begin t:=i+j; while (t<(i+1)*i div 2)and(t<=m) do t:=t+i; ss:='0'; while t<=m do begin zz:=a[t]; a[t]:=plus(a[t-i],ss); t:=t+i; ss:=zz; end; end; if m<((i+1)*i div 2)-1 then pus:=m else pus:=((i+1)*i div 2)-1; for z:=1 to pus do a[z]:='0'; sum:=plus(sum,a[m]); end; writeln(sum); end. > const n=500; > var a:array[1..n]of string; > i,j,k,l,m,rk,v,t,z,pus:longint; > sum,ss,zz:string; > function mmm(p:longint):longint; > begin > v:=1; > while ((v+1)*(v+2)) div 2<=p do v:=v+1; > mmm:=v; > end; > function plus(pluss1,pluss2:string):string; {only pozitive!!!} > var plusi,pluscode,plusi1,plusi2,plusna,plusba:integer; > pluss,plusss:string; > begin > if pluss1='' then pluss1:='0'; > if pluss2='' then pluss2:='0'; > pluss:=''; > while length(pluss1)<length(pluss2) do pluss1:='0'+pluss1; > while length(pluss2)<length(pluss1) do pluss2:='0'+pluss2; > plusna:=0; plusba:=0; > for plusi:=length(pluss1) downto 1 do begin > val(pluss1[plusi],plusi1,pluscode); > val(pluss2[plusi],plusi2,pluscode); > plusba:=(plusi1+plusi2+plusna) mod 10; > plusna:=(plusi1+plusi2+plusna) div 10; > str(plusba,plusss); > pluss:=plusss+pluss; > end; > if plusna<>0 then begin > str(plusna,plusss); > pluss:=plusss+pluss; > end; > plus:=pluss; > end; > begin > readln(m); > for i:=1 to m do a[i]:='1'; > sum:='0'; > rk:=mmm(m); > for i:=2 to rk do begin {ЇҐаҐЎ®а Ї® k} > for j:=1 to i do begin > t:=i+j; > while (t<(i+1)*i div 2)and(t<=m) do t:=t+i; > ss:='0'; > while t<=m do begin > zz:=a[t]; > a[t]:=plus(a[t-i],ss); > t:=t+i; > ss:=zz; > end; > end; > if m<((i+1)*i div 2)-1 then pus:=m else pus:=((i+1)*i div 2)- 1; > for z:=1 to pus do a[z]:='0'; > sum:=plus(sum,a[m]); > end; > writeln(sum); > end. You turned out to be a lamer yourself. go learn C or C++. your solution is verry stupid. I think only one lamer could solve the problem like this. I wrote only 22 lines. Of course, Pascal suks. what does your program mean? program ural1017; var q:array[0..500]of int64; n,i,j:integer; begin fillchar(q,sizeof(q),0); readln(n); q[0]:=1; for i:=1 to n do for j:=n downto i do inc(q[j],q[j-i]); writeln(q[n]-1); end. This code is beautiful. Can you explain it please? Thanks This code is beautiful. Can you explain it please? Thanks This code is sux. I wrote it with C++. It answers 0 with any input =\ And, yes, I wrote it right. #include <iostream> using namespace std; int main(void) { short n; cin >> n; long long a[501]; for (short i=0; i<501; i++) a[i]=0; a[0]=1; for (short i=1; i<=n; i++) for (short j=n; j>=i; j--) a[j]+=a[j-1]; cout << a[n]-1; return 0; } It writes 0 with any input cuz we n times doing operation a[j]=a[j-1] for j from n to i. Of course the 1 we placed in the beginning goes to the a[n]. Then we are outputting a[n]-1, witch of course will be 1-1=0. The only good in this code that I saw was that this code can generate Pascal's triangle. Artem, good one! Красава) Доставил твой пост:) This works. How did you come to this short solution:)? haha, why anyone use array with length 500? just try to think a little, program need array with length no more 32! LOL! the only lamer here is "Yuriy Frolov (ufrolov@ukr.net)"-:D :D :D Your program is worst i've ever seen :D :D :D You chose stupidest way to solve and you think that others are lamers??? :D it would be better to hide this solution except to submit it :D | Troll Problem | Suraj | 1723. Книга Сандро | 26 окт 2015 21:58 | 2 | This problem is just to troll you. I first thought of doing it using suffix array. Just read the question properly, it says 'any substring'? Didn't you see constraint bro -_- Length is 50 and suffix array :V | why WA test#1 | magzhan | 1141. Взлом RSA | 25 окт 2015 14:30 | 4 | Now TL on test#1, what's wrong, I don't understand everything I also got AC out there. 250 ms. 1300 kb. Here I got TLE. 102 kb. using long long rather than int | I would like to know how to solve this problem faster, as I pass it with 2.8s. | lyonlys | 2062. Амбициозный эксперимент | 25 окт 2015 00:20 | 1 | My solution: Cutting the array into blocks, so I can now update a segment with O(sqrt n) each query; therefore, I can get the increase in O(1) while scanning each factor (at most 180 in total). It is obvious that I should prepare all the factors for each number. The complexity of the algorithm is O((sqrt(n) + 180) * m + 180 * n). and .. I reduce a lot of modular and divide operations to get this AC. :P Edited by author 25.10.2015 00:21 | No subject | olga_lav | 1263. Выборы | 24 окт 2015 00:40 | 1 | Edited by author 26.10.2015 23:24 | Accepted C# | moscal_ | 1000. A+B Problem | 23 окт 2015 21:56 | 1 | using System; class First { static void Main() { String[] ss = Console.ReadLine().Split(); Console.WriteLine (int.Parse(ss[0]) + int.Parse((ss[1])); } } | WA #2 | ile | 1151. Радиомаяки | 23 окт 2015 19:02 | 3 | WA #2 ile 26 окт 2010 04:54 Anyone knows what's the problem with 2nd test? any ideas, please!! Found it. Misunderstood the problem. how to say....I WA#2 too however cannot find my mistakes....... | why the output of the sample is not 64631000033? | Bohe | 1343. 12 месяцев | 23 окт 2015 16:56 | 2 | do i misunderstand the meaning of this problem? 64631000033 is a prime,why it not the right answer of the sample? please help me!thanks! If 64631000033 is a prime, it's also good. You should output any, not necessarily minimal. | No subject | Rostislav | 1343. 12 месяцев | 23 окт 2015 11:38 | 4 | As far as I understand the tasks the 12 digit number should be prime. Can it have leading zeros? Can the number 646310000033 be a corect output for the sample input? And how to format long long (was it "%I64" ?)? Rostislav Edited by author 19.02.2005 15:48 got AC +17... it SHOULD have leading zeros. L CAN be 0 digits CAN be separated by blanks. ALL IS MY IMHO The problem was in the formating (always forget that the compiler is differnt from my own). i have the same question as you,why is 64631000033 not the right answer,can you tell me,please? | WA 12 | buea | 1635. Мнемоника и палиндромы | 23 окт 2015 07:18 | 2 | WA 12 buea 23 окт 2015 06:59 Stuck at test case #12 Per reply in 2008, someone suggested testing with axayaaxa I don't know whether this is the real #12. But I tried anyway. My program answers a x aya axa And another possible answer is axa y a axa Both with 4 palindromes. Question says output any is correct. Suggestion? Thanks in advance! I spotted a bug. Will fix it first and try again. | wrong ans #4.Is there any test. | Bahodir | {TUIT} | | 1131. Копирование | 22 окт 2015 17:44 | 3 | import java.util.Scanner; /** * Created by Coder on 05.12.2014. */ public class Copy1131_ { public static void main(String[] args) { Scanner x = new Scanner(System.in); int n = x.nextInt(); int k = x.nextInt(); int time = 0, i = 1; long s = 1; while (s < n) { if (i >= k) { s += k; } else { s += i++; } time++; } System.out.println(time); } } | что не так? Python 3 | Олег | 1001. Обратный корень | 20 окт 2015 14:22 | 1 | from math import sqrt s=input().replace("\n"," ").split() x=[sqrt(int(i)) for i in s] x.reverse() for i in x: print("%.4f"%i) | I need Test Number 3... Or some advise | vitoshacademy | 2046. Первый раз в первый класс | 20 окт 2015 12:38 | 4 | Pretty much, my program runs as correctly as I can think of... I am even trying with input such as: 9 Physics education education Thursday 3 Maths education AND A LOT OF FUN FUN1 FUN LOT OF FUN FUN1 FUN FUN education education Tuesday 1 Chemistry education Thursday 1 Physical education1 education Saturday 2 Astronomy Saturday 4 Urban geography AND A LOT OF FUN FUN1 FUN LOT OF FUN FUN1 FUN FUN education educationA LOT OF FUN FUN1 FUN LOT OF FUN FUN1 FUN FUN education educationA A LOT OF FUN FUN1 FUN LOT OF FUN FUN1 FUN FUN education education Tuesday 4 A A A A A A A A A A A A A A A A A A A A A A AA A A AA AA A A AAA AA A A A A AA A A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A A A AA A Saturday 1 Modeling Thursday 2 Biology Thursday 4 1 education Thursday 2 And it still works. What is test number 3? Try to test the following. 1 iammasterj Tuesday 1 may be it is test 1 vasya like computers Thursday 1 | Easy :D | mr_sinjster | 1352. Простые числа Мерсенна | 20 окт 2015 02:02 | 1 | Easy :D mr_sinjster 20 окт 2015 02:02 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Numerics; using System.Threading.Tasks; namespace T1 { class Program { static void Main(string[] args) { int n = int.Parse (Console.ReadLine ()); int[] data = new int[]{2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457, 32582657, 37156667, 42643801, 43112609, 57885161}; int[] result = new int[n]; for (int i = 0; i < n; ++i) result [i] = data [int.Parse (Console.ReadLine ()) - 1]; for (int i = 0; i < n; ++i) Console.WriteLine (result [i]); } } } | Wrong answer test 3 in Java 1.7 please help me | Axmadjon | 1496. Спамер | 19 окт 2015 21:43 | 2 | import java.util.Arrays; import java.util.Scanner; public class _1496 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int amount = s.nextInt(); if (amount == 0) System.out.println("0"); else { String[] source = new String[amount]; String[] uniT = new String[amount]; int j = 0; int count = 0; for (int i = 0; i < amount; i++) { source[i] = s.nextLine(); } Arrays.sort(source); uniT[0] = source[0]; for (int i = 0; i < amount; i++) { if (source[i].equals(uniT[j]) != true) { j++; uniT[j] = source[i]; } } for (int i = 0; i <= j; i++) { count = 0; for (int k = 0; k < amount; k++) { if (source[k].equals(uniT[i])) { count++; } } if (count > 1) { System.out.println(uniT[i]); } } } } } You have to change Output in case of empty solution from "0" to Empty string. It will solve your problem |
|
|