Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | No subject | green_smile | 1904. Уроки прошлого | 13 окт 2012 15:25 | 6 | Edited by author 14.10.2012 00:59 Edited by author 14.10.2012 00:59 числа из отрезка подходят под нормальный сигнал! Edited by author 14.10.2012 00:59 | | Pascal vs C/C++ :( | Adil_INF-11_BQU | 1263. Выборы | 13 окт 2012 15:06 | 30 | I solved this problem on Pascal and was AC. But i wrote same program on C and C++. It gives same answers on same tests on my machine but gives WA on test 1 when i submit. These my programs: On pascal:: var a:array[1..10000] of integer; k,n,m,i:integer; s:longint; procedure cle; var i:integer; begin for i:=1 to n do a[i]:=0; end; begin read(n,m); cle; s:=0; for i:=1 to m do begin readln(k); if k<>0 then inc(a[k]); end; for i:=1 to n do begin if a[i]<>0 then writeln(a[i]/m*100:2:2,'%') else writeln('0.00%'); end; end. On C: #include <stdio.h> void main(){ int k,n,m,i; int a[10000]; scanf("%d %d\n",&n,&m); for (i=1;i<=n;i++) a[i]=0; for (i=1;i<=m;++i){ scanf("%d",&k); if (k!=0) a[k]++; } for (i=1;i<=n;++i){ if (a[i]!=0) printf("%2.2f%\n",(float)a[i]/m*100); else printf("0.00\n"); } } 1) Use "double" instead of "float". 2) Don't use Pascal, 'cause C++ is really cool language. P.S. I don't understand how can people write theese "begin ... end" so many times? LOL ^_^ (+) Dmitry 'Diman_YES' Kovalioff 3 фев 2006 15:46 I don't understand people who think they are cool enough to speak such foolish things ;) Pascal is not worse than C++, and it is up to one to choose what language to use - as for me I use Pascal and I am in Top 10 :) Safe Bird uses C++ - but he does not scream that C++ is better... P.S. Sorry, can not control myself when Pascal in under attack ;) +++ +FAMAS+ 3 фев 2006 22:09 RESPECT++++++ PASCAL RULEZZZ!!!! Re: +++ Vladimir Yakovlev (USU) 4 фев 2006 00:22 Hmm... Pascal is not spported at World Finals now. Best programmers have started using Java. Maybe Timus must do the same - substitute Pascal to Java. Don't you want to double all timelimits for "fast" Java programs to pass them? :))) Re: +++ Adil Aliev INF-11(BSU - app. math.) 4 фев 2006 03:27 oooh. Yesss. Java is good. I will glad if timus add Java compiler to this contest "Pascal is not spported at World Finals now" - с этого года что ли? Re: +++ Vladimir Yakovlev (USU) 4 фев 2006 14:42 Pascal provided but not supported read this: http://icpc.baylor.edu/systems/finals/pascal.htm Pascal will not be removed from Timus of course. Java will be added as soon as possible, but not to February, 11. It is possible to recalculate all timelimits for Java. But it is impossible to make all problems solvable in Java. Edited by author 04.02.2006 15:05:) ACM.Tolstobrov_Anatoliy[Ivanovo SPU] 4 фев 2006 18:58 deleted Edited by author 26.10.2018 14:38 Re: :) ACM.Tolstobrov_Anatoliy[Ivanovo SPU] 4 фев 2006 19:01 deleted Edited by author 26.10.2018 14:37 Re: +++ Fyodor Menshikov 13 фев 2009 23:53 Re: +++ Vedernikoff Sergey (HSE: EconomicsForever!) 16 фев 2009 03:38 And why it is problem to solve it in Java? What we need for solution - just one array int[1000] But I really don't understand why timelimit is so small - memory is not crucial part of this problem at all... Re: +++ Fyodor Menshikov 16 фев 2009 12:16 memory is not crucial part of this problem at all... Maybe author wanted to cut off DP way of solving this problem or something like this. I did't say that Pascal is bad, nasty, ugly, damned language or something like it. But... U must agree with me that up to now there is no compiler for Pascal that can be compared with MVC++ or g++. Theese make really good machine code. :) And IMHO this language is uncomfortable to write algorithms and serious projects. What for Top 10... over some year Top 10 or even Top 50 can became consisting only of Pascal (or - that's terrible - Java) users. Even BASIC coders could be cool because they ARE cool. You think we prefer language? Often programming language prefers us. Pascal is popular in Russia just because of traditions begun with 80's. P.S. I accept your apology, but "LOL" is offensive, don't you think? ДИМАН VERY GOOD MAN, НАПИСАЛ LOL, НАПИШИ ЕМУ ТАКЖЕ:) I suggest to make a voting. I use pascal about 5 years for solving problems. And as for me, I think that pascal is not so uncomfortable to write algorithms. Edited by author 07.02.2006 21:39 Hi! I'm first time here and seems the last - cause there is no Java support. Are you going to add it soon? Pascal is the worst language I ever seen..... Shut up! Pascal Will Newer Die! Edited by author 18.10.2006 08:05 In C++ very hard syntax, and Pascal is good language too Currently I'm using C++ for solving problems, but can say: Pascal foreva! C++ has many drawbacks which are worse than just long "begin .. end" I solved problems using all languages available on this server and Java seems to be most convenient for me.. #include <iostream> #include <stdio.h> using namespace std; int main() { int br[10024],i,m; double n,a; float sum; cin>>n>>a; sum=100/a; for(i=1;i<=10024;i++) { br[i]=0; } for(i=1;i<=a;i++) { cin>>m; br[m]++; } for(i=1;i<=n;i++) {
printf("%.2lf",(br[i]*sum)); cout<<"%"<<endl; } return 0; } 1) Look how your C++ program will work with n=10000;) 2) You've forgotten about percent sign in else printf("0.00\n"); 3) Don't use % in printf, use %% (it will show as %) 4) LEARN C++ well before writing on it! Edited by author 03.02.2006 17:57 >> 2) You've forgotten about percent sign in else printf("0.00\n"); Is it really necessary? Can anyone translate my solution below into C++? I want to learn programming in C/C++ too :) type TArray=array of dword; var arr:TArray; m,n,c,i:dword; begin readln(n,m); setlength(arr,n+1); for i:=1 to n do arr[i]:=0; for i:=1 to m do begin readln(c); arr[c]+=1; end; for i:=1 to n do begin writeln((arr[i]*100/m):2:2,'%'); end; end. | | Who can help me about the Sample? | TLaum | 1106. Две команды | 13 окт 2012 12:53 | 5 | if input is sample input,can output be : 2 3 6? And why?thx Yup, output is correct, because 3 is a friend with 1, 2, 4, 5 and 6 is a friend with 7. So each member of each team has at least one friend in the opposite team Yup, output is correct, because 3 is a friend with 1, 2, 4, 5 and 6 is a friend with 7. So each member of each team has at least one friend in the opposite team wtf? why 6 and 7 are friends? this problem don't only a result!!! | | How can we make this results -- 0.001 sec -- 1 128 KB ? | sylap | 1290. Саботаж | 12 окт 2012 19:27 | 2 | How can we make this results -- 0.001 sec -- 1 128 KB ? This is the best result for this problem. I wonder how can we get this results. You can see this result by clicking the link Solution Rating on problem statement. :: http://acm.timus.ru/rating.aspx?space=1&num=1290 :: Edited by author 08.10.2012 12:45 Edited by author 08.10.2012 12:46It is not possible to achieve 0.001 sec result with the current judge. The measurement for an empty program that only calls puts("\n"); is 0.015 at this time. Until the measurement mechanism is changed, those who submitted results years ago will be the only ones to achieve 0.001. | | What about 9 test | Alexander Goncharov | 1407. Раз-два, раз-два | 12 окт 2012 14:22 | 2 | Give 9 test please. Edited by author 12.10.2012 14:16 Edited by author 12.10.2012 14:16 My program print this result: 9 212122112 | | Tips of WA3 and WA2 | h2952220 | 1019. Перекрашивание прямой | 11 окт 2012 19:01 | 1 | 1.Pay attention 0 < ai < bi < 1e9. (I forgot the 0 and 1e9 axis...then wa teat 2 for many time) 2.The data of test 3 maybe 1 1 1000000000 b answer: 0 1 I make an error while recursion to the leaf note. I return the l index instead of the axis it map to. T T Edited by author 11.10.2012 19:04 | | clarification | Korduban [Kiev] | 1578. Охота на мамонта | 11 окт 2012 16:10 | 6 | Angles must be strogly acute? I.e., right angles (pi/2) are restricted? It is now absent, but before the sample was corrected there was right angle... My AC solution rejects right angles I got AC when I deleted right angles. I had WA before that. | | Clearly, 0.015 is the new 0.001 | Bogatyr | 1243. Развод семи гномов | 11 окт 2012 15:37 | 3 | It seems timing has changed since the earlier years on the server. When the following program gets WA in 0.015, you know 0.001 is not possible any more: #include <stdio.h> int main() { puts( "0" ); } Too bad that those of us solving problems now don't get time rated on the same scale as those who came before. But if your code work 0.5 now, in 2003 he worked more than 1 sec The fact that computers are faster today is not the point. In fact, it makes the 0.015 vs. 0.001 difference even more crazy -- computers today are *not* 15 times slower than in 2003! Obviously it is a difference in time measurement technique or a system difference that causes the measurements to differ. When such a measurement difference occurs, all problems should be re-rated for time, it's impossible to compete for time rating on O(1) problems when the fastest possible measurement today for an empty program is 15 times greater than it used to be. | | No subject | Ahmet Faruk Ozkan OTTOMAN(Devlet - i Âliye)) | 1020. Ниточка | 10 окт 2012 22:11 | 1 | No subject Ahmet Faruk Ozkan OTTOMAN(Devlet - i Âliye)) 10 окт 2012 22:11 must I roped off all the nails with shortest rope? | | When m==1 the answer is 1 not 0 | Test | 1224. Спираль | 10 окт 2012 20:13 | 1 | | | Hints For Those Who Got TLE | Zero | 1120. Сумма последовательных чисел | 10 окт 2012 18:54 | 7 | Use the formula: N=[a+(a+p-1)]*p/2,and you will got the formula of A: A=[ 2*N/P +1-p]/2 Loop p to find A,that's what someone else in this forum suggested. But even in this way some people got TLE as well.I guess you start looping P from 10^9... In fact you can find that 2N/P +1-P >0,solve this inequality,you will find p is <[1+sqrt(1+8N)]/2. You can cut the time of the loop down to half or even less in this way. I'll explain it to you in Chinese tomorrow...How did you find my post? this problem has solution O(sqrt(2N)) 'cause 2N = P(2A+P-1) N, P, A is natural, so P is divider of 2N, so algo is simple scan N, multiply N by 2, then for each divider of this new N less then sqrt(N) try to find p = divider or n / divider, a = (a - p + 1) / 2, where a supposed to be natural, if out p bigger than our saved one - replace saved one. out our bigger result Loop P from 44720 downto 1 and check out these two conditions to be true: 1) N>=P(P+1)/2; 2) P divides (N-P(P+1)/2). Break as fast as you find the first one. Then A=1+(N-P(P+1)/2)/P. If you still can't get it, look at the following lines. 1+2+3+4+5=15 2+3+4+5+6=20 3+4+5+6+7=25 4+5+6+7+8=30 Et cetera. | | Why my programm is wrong ? | Aleksey S.S. | 1255. Кладбище мафии | 10 окт 2012 18:31 | 4 | >var n,k,ans1,ans2:longint; > >begin > read(n,k); > if n<k then write('0') else begin > ans1:=(n div k)*(n + n mod k); > ans2:=(n-k)*4; > if ans1>ans2 then write(ans1) else write(ans2); end; >end. My program is very short. My method is like yours and I can't find the bug in it. What was wrong with yours? For 8 3 answer is 21, not 20 | | I’ve AC, but I still have a question! | Veniamin | 1224. Спираль | 10 окт 2012 17:32 | 3 | I’ve AC, but I still have a question! My first program used “unsigned long” type, and didn’t pass Test 12 Then I changed all types to “unsigned long long” , and program was AC. So, my question is why my first program failed on Test12? As you know n,m<=2^31-1;So, the biggest result is 0xFFFFFFFD! This result can be represented by unsigned long! So, I didn’t announce my program, because it is bad style. I’m sure that those programmers who solved this issue can understand my question…. Best Wishes, Veniamin. Each of n and m is <= 2^31-1. Yes, they are unsigned long. But max unsigned long + 1 is? Overflow, of course !! Your solution doesn't print n or m exactly but you have to calculate either 2*m or 2*n, aren't you? Thanks.I also meet this question. | | help, please; i can't get AC, but i know that my program is wright | Foxy | 1068. Сумма | 10 окт 2012 11:53 | 3 | > here is my source (C++): --------------------------- #include <stdio.h> int i;long sum=0; int n; void main() { scanf("%d",&n); if(n<1) for(i=1;i>=n;i--) sum+=i; else for(i=1;i<=n;i++) sum+=i; printf("%ld",sum); } -------------------------- Try to delete void because i did so , and my programm was right good Luck ! | | Which alhoritm? | Abbath1349 | 1889. Объявление в аэропорту | 10 окт 2012 00:27 | 1 | can you say which alhoritm it is? topologial sort? | | Help PLEASE, i don't understand | green_smile | 1821. Биатлон | 9 окт 2012 23:27 | 2 | input 6 Zaitseva 21:38.2 Hauswald 21:21.0 Boulygina 22:04.4 Henkel 22:06.1 Wilhelm 21:11.1 Jonsson 22:05.8 My program: 4 Hauswald Henkel Wilhelm Zaitseva explain me please what's wrong??? why Henkel isn't in Test? it's code program z1821; var n,i,j,m,x,max,ol:integer; s,s1:string; names:array[1..100]of string; times:array[1..100]of integer; reznames:array[1..100] of string; begin readln(n); j:=1; for i:=1 to n do begin readln (s); while s[j]<>' ' do begin inc(j); end; names[i]:=copy(s,1,j); // delete(s1,1,length(s1)); // s1:=copy(s,j+1,2); // val(s1,times[i],ol); // delete(s1,1,2); // s1:=copy(s,j+4,2); // times[i]:=times[i]*600; // val(s1,x,ol); // times[i]:=times[i]+x*10; // delete(s1,1,1); // s1:=copy(s,j+7,1); // val(s1,x,ol); // times[i]:=times[i]+x; // j:=1; //it's input, don't look on it =) end; for i:=2 to n do times[i]:=times[i]-300*(i-1); max:=times[1]+1; m:=0; j:=1; for i:=1 to n do begin if times[i]<max then begin max:=times[i]; reznames[j]:=names[i]; m:=m+1; j:=j+1; end; end; for i := 1 to m-1 do for j := 1 to m-i do if reznames[j] > reznames[j+1] then begin s1 := copy(reznames[j],1,length(reznames[j])); reznames[j] :=copy(reznames[j+1],1,length(reznames[j+1])); reznames[j+1] :=copy(s1,1,length(s1)); end; writeln(m); for i := 1 to m do writeln(reznames[i]); end. Edited by author 09.10.2012 23:47 | | Wrong answer 4! Please help! | Grigorenko Vlad | 1131. Копирование | 9 окт 2012 16:31 | 2 | #include<stdio.h> int main(void){ int n,k,time,n1,i; scanf("%d%d",&n,&k); i=1; n1=1; time=0; while(n1<k && n1<n){ n1=n1+i; i++; time++; } if(n - n1>0){ if((n-n1) % k == 0) time=time+(n-n1)/k; else time=time+(n-n1)/k+1; } printf("%d",time); return 0; } Hints: 1) your while loop condition is not quite right. 2) you are not growing n1 properly in the while loop 3) your "if (n - n1>0)" is not necessary, if n-n1 == 0 then the division result will be zero 4) integer ceiling of x/y can be done in a single step like this: (x + y - 1)/y 5) it's generally a good idea to finish each line of output with a newline character In general: do some examples on paper, and step through your code in the debugger, or put in a bunch of print statements to follow the progress of the solution, and you'll discover where the problems are. | | I have WA5. Please check my tests | <-UnderFelixAbove-> | 1377. Лара Крофт | 9 окт 2012 08:46 | 5 | I don't know what problem in my program. That's why I ask you to check my tests: 100 100 1 1 50 50 9996 100 100 5 3 65 34 7783 5 6 1 1 5 6 9 2 2 1 2 2 1 1 5 5 1 1 3 3 24 I am waiting your comments. Thank you. Hello! The answer for this test: 2 2 1 2 2 1 is "2", but your answer is "1". Good luck! Thank you Master! I'm so careless)). Btw, in test #5 N = M = 100. I made inaccurate array definition and get this information. :) My program didn't pass #5 test, because not correctly process the case when N = 2, M > 2 or M = 2, N > 2. | | what is wrong | mahmoudnoaman | 1001. Обратный корень | 9 окт 2012 06:24 | 1 | // modify precision #include <iostream> #include<math.h> #include<limits> using namespace std; int main () { //typedef std::numeric_limits<double>dbl; double A; double B; cin>>A; B=sqrt(A); cout.setf(ios::fixed); cout.precision(4); cout<<fixed<<B<<endl; return 0; } | | No subject | Radiovoin | 1196. Экзамен по истории | 9 окт 2012 02:44 | 1 | Edited by author 09.10.2012 02:55 |
|
|