Common Board| Show all threads Hide all threads Show all messages Hide all messages | | 1001. Runtime error. Java | Java.Xotatel | 1001. Reverse Root | 27 Oct 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. Nontrivial Numbers | 27 Oct 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. Staircases | 27 Oct 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. Sandro's Book | 26 Oct 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 Attack | 25 Oct 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. Ambitious Experiment | 25 Oct 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. Elections | 24 Oct 2015 00:40 | 1 | Edited by author 26.10.2015 23:24 | | Accepted C# | moscal_ | 1000. A+B Problem | 23 Oct 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. Radiobeacons | 23 Oct 2015 19:02 | 3 | WA #2 ile 26 Oct 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. Fairy Tale | 23 Oct 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. Fairy Tale | 23 Oct 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. Mnemonics and Palindromes | 23 Oct 2015 07:18 | 2 | WA 12 buea 23 Oct 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. Copying | 22 Oct 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. Reverse Root | 20 Oct 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. The First Day at School | 20 Oct 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. Mersenne Primes | 20 Oct 2015 02:02 | 1 | Easy :D mr_sinjster 20 Oct 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. Spammer | 19 Oct 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 | | 出题人严重脱离现实生活 | gaoshangbo | 1753. Bookshelf | 19 Oct 2015 16:47 | 4 | It's hard to dispute with you! :)))) | | Some useful tests | yeziqing10 | 1216. Two Pawns and One King | 19 Oct 2015 11:55 | 1 | 8 a2 b3 h1 WHITE WINS 8 a2 b3 g2 BLACK WINS 8 d6 e7 e6 BLACK WINS (if you use DP as me, the following tests are useful) 8 a6 h2 g2 WHITE WINS 8 a2 b3 g3 BLACK WINS 8 a2 b4 h1 BLACK WINS 8 a2 b3 h1 WHITE WINS The problem is really good. It makes me more considerate and ..trains my patience... | | Test 9 | Agabek | 2008. Swifty | 19 Oct 2015 02:57 | 3 | Test 9 Agabek 10 Nov 2013 00:11 Re: Test 9 Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 10 Nov 2013 15:41 Don't know what kind of test it is, but precision troubles are quite likely in this problem. So, solve problem in integers to avoid them. I had WA on test 9 with a wrong formula for the movement equations, that worked on the samples, but was too weak to solve these tests (it would say "yes" to both): 14 0 20 0 10 0 0 Yes 14 0 20 0 9 0 0 No |
|
|