Common BoardСергей used only small letters or There can be Title LETTERS I wrote this program without that; but it is true, that the little letter and the big letter are DIFFERENT. По русски: Заглавные и сторчные буквы РАЗЛИЧАЮТСЯ. мое решение прошло! Napishi reshenie сам думай!!!!! это ж легко... можно делать так a[i][1] 谁有测试数据(chinese) Edited by author 18.03.2009 10:41 Edited by author 18.03.2009 10:41 Edited by author 19.08.2010 19:09 Edited by author 19.08.2010 19:09 1 - 2 3 1 4 5 2 - 3 1 2 4 5 3 - 2 3 1 4 5 1 and 3 are same No, 3-1 2 3 4 5. The digit always mean index for the first line. but i can't find answer 3 with LCM? 2&3&1 is a loop with length 3 4 is a loop with length 1 5 is a loop with length 1 LCM(3,1,1)=3 2&3&1 is a loop with length 3 Edited by author 19.08.2010 16:11 ok.I understood. Edited by author 19.08.2010 16:21 Say it in this way: select an arbitraty number n, let i=n; while( P(i)!=n ) i=P(i); all the numbers "involved" makes a loop. in case 2 3 1 select n=2,i=2; P(i)=3 so i=3; P(i)=1 so i=2; now i=n, exit loop; You can prove the following statement: if a loop has X elements, then after exactly X permutations, every elements in the loop is on its proper position in EN. is that clear? Since you are very good in maths, you may prove it yourself. yes my math is good. But i begun to learn programming since 18. Due to it I am not very good at finding algorythm. Do you know really good book with examples for learning algorythms. Sorry I only know books written in Chinese. May be it is translation from English or Russian All I know are written by Chinese authors. cormen introduction to algorithms (pdf) Knuth and other) yes my math is good. But i begun to learn programming since 18. Due to it I am not very good at finding algorythm. Do you know really good book with examples for learning algorythms. The number just mean the quantity of P() in total. P4(n)=P(P(P(P(n)))). Some time in math we write this '2' in the bottom-left corner, but that doesn't make much difference. haaaaaaaaaaaaaaaaaaaa......................... Realyy very thanks buddy. I made a mistake. It should be bottom-right corner var a:array[0..10000]of integer; max,i,j,n,k,l,group1,group2:longint; begin read(n); for i:=1 to n do read(a[i]); for i:=1 to n-1 do begin k:=i; max:=a[i]; for j:=i+1 to n do if a[j]>max then begin max:=a[j]; k:=j; end; a[k]:=a[i]; a[i]:=max; end; for i:=3 to n do if group1<group2 then group1:=group1+a[i] else group2:=group2+a[i]; writeln(abs(group1-group2)); end. this is wrong approach. the right solution is DP or bruteforcing all combinations. Someone have function DP of this problem use BruteForce my program with it works good difficulty of my algorithm is O(n* pow(2,20) = O(n*1048576) ... Three different *postitve* integers (a, b and c) ... Есть еще вот какое предложение: 1) в топе по лучшим отправкам создать возможность выбрать язык лучших отправок... чтобы видеть лучшие программы на С++, Паскале, С#, JAVA отдельно 2) Чтобы в лучших отправках сортировалось не только по времени, но и по кол-ву используемой памяти. (сейчас не так, видел отправки с лучшей памятью на худших местах) Edited by author 16.08.2010 16:30 Да, согласен. Еще неплохо было бы самому выбирать компилятор для C++. I think, that advanced statistics of profile was a good idea. Why do you hide it? Edited by author 16.08.2010 18:45 Do you really think this is well done? Where is my full statistics now? Yep! Its all you need to know! What for you need other statistic? Its useless. I don't agree with you. This statistics says an advanced information about you as a programmer. And as a mathematician too :) 2 bsu.mmf.team I agree with you. IMHO admins should return to previous design. Hi, I tried to use java to solve this problem but failed, yet do not know where is the bug, I have pasted the source code here, wish someone can help me out. I am very very grateful. public class ReversRoot1001 { public static void main(String args[])throws IOException{ BufferedReader br = new BufferedReader(new FileReader("ReversRoot1001.txt")); Vector<Integer> record = new Vector<Integer>(); String line; while((line = br.readLine())!=null){ Scanner sc = new Scanner(line); int a = sc.nextInt(); record.add(a); // if(sc.hasNext()){ // int b = sc.nextInt(); // //int c = sc.nextInt(); // record.add(b); // } while(sc.hasNext()){ int b = sc.nextInt(); record.add(b); } } for(int i = record.size();i<record.size();i--){ System.out.println(record.get(i)); } br.close(); } } Use standart input/output. And don't use Scanner - it's very slow. Look: BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer tok = null; String readToken() throws IOException { // reads the token; to read a full line use in.readLine() while (tok == null || !tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); } return tok.nextToken(); // sometimes it's better to use nextToken(String) method here } int readInt() throws IOException { // write readDouble(), readLong(), readBigInteger() methods if necessary return Integer.parseInt(readToken()); } And, finally, don't forget to write out.flush() at the end of your program! Edited by author 17.08.2010 21:26 Moonstone Thank you so much for your help. I am very grateful! Edited by author 18.08.2010 06:21 what would be the distance between point (0,0) and square (1,0) (-1,0)?? Is it equal 0 or 0.7?? "If P is inside the square then the distance is zero" So, the distance is 0. Does anyone knows what is tested in the test 6??? Or anyone have examples???? I had WA#6 too. Didn't use 'string' object because it is have char size of i-th element (-128,127), but you need more. Edited by author 17.08.2010 12:17 Gettin' wrong answer. Can anybody post it, please!? 10 2 5 1 1 6 1 4 4 5 5 8 7 9 Answer: 5 1 2 3 4 5 May be test 7 is another thing.I don't know exactly. Edited by author 16.05.2009 11:57 I got wa7 too. But my algo give right answers in all tests at timus :( I use sort and greedy :( I don't understand why sort and greedy not work? this is not test 7 this test works for me i also use sort + greedy and i dont know why i get wa7 Try this one: 10 3 5 1 1 2 1 5 1 7 6 8 4 9 The answer is: 5 1 2 3 4 5 If you encounter any problems please describe it in this thread. Thanks a lot!!! The default stack size is set to 64 MB now. I think that test 16 have at least two codirectional vectors. Incorrect test is fixed. Thank you. My AC solution crashes on this test 2 2 ** ** Problem statement is updated. Read "Site news". #include <stdio.h> #include <math.h> #define M_PI_4 0.785398163397448309616 double d[51] = {0}; char printed[51] = {0}; struct point { double x; double y; }; struct square { point a; point b; } squares[51]; point rotate(point a, double d_al){ point _a; _a.x = a.x * cos(d_al) - a.y * sin(d_al); _a.y = a.x * sin(d_al) + a.y * cos(d_al); return _a; } double get_d(point a, point p) { return sqrt((double)((a.x - p.x)*(a.x-p.x) + (a.y -p.y)*(a.y - p.y))); } int main () { int n; scanf("%d",&n); point p; int i; for (i=1;i<=n;i++) { scanf("%lf%lf%lf%lf", &squares[i].a.x,&squares[i].a.y,&squares[i].b.x,&squares[i].b.y); } scanf("%lf%lf", &p.x,&p.y); double tn; double alpha,d_al; point _a,_b,_p,a,b,temp; for(i=1;i<=n;i++) { b = squares[i].b; a = squares[i].a; if(a.x == b.x && a.y == b.y) { d[i] = get_d(p,a); continue; } tn = (double)(b.y - a.y)/(double)(b.x - a.x); alpha = atan(tn); d_al = M_PI_4 - alpha; _a = rotate(a,d_al); _b = rotate(b,d_al); _p = rotate(p,d_al); if( _a.x > _b.x) { temp = _b; _b = _a; _a = temp; } if(_p.y > _b.y) { if(_p.x < _a.x) { temp.x = _a.x; temp.y = _b.y; d[i] = get_d(_p,temp); continue; } if(_p.x > _b.x) { d[i] = get_d(_p,_b); continue; } d[i] = _p.y - _b.y; continue; } if(_p.y < _a.y) { if(_p.x > _b.x) { temp.x = _b.x; temp.y = _a.y; d[i] = get_d(_p,temp); continue; } if(_p.x < _a.x) { d[i] = get_d(_p,_a); continue; } d[i] = _a.y - _p.y; continue; } if(_p.x < _a.x) { d[i] = _a.x - _p.x; continue; } if(_p.x > _b.x) { d[i] = _p.x - _b.x; continue; } d[i] = 0; } double min; int j,k; for(i=1;i<=n;i++) { min = 99999999999999999; k = 0; for(j=1;j<=n;j++) if(!printed[j] && min > d[j]) { min = d[j]; k = j; } printed[k] = 1; printf("%d ", k); } return 0;} Don`t forget about d = 0 and p = 1, =) Edited by author 16.08.2010 03:58 What change if shift beginning time of the exam to more early time ? Please explain to me. Thank! > What change if shift beginning time of the exam to more early > time ? Please explain to me. Thank! 70 + 40 = 110 // first student (70 40 150) 110 + 15 = 125 //second one (99 15 400) 125 + 10 = 135 // third one (100 10 120), he is 15 min late, (he's to be free at 120) i hope it helps. > > What change if shift beginning time of the exam to more early > > time ? Please explain to me. Thank! > > 70 + 40 = 110 // first student (70 40 150) > 110 + 15 = 125 //second one (99 15 400) > 125 + 10 = 135 // third one (100 10 120), > he is 15 min late, (he's to be free at 120) > > i hope it helps. > does this mean third should start at 110 and second start at 110+10=120? > > > What change if shift beginning time of the exam to more early > > > time ? Please explain to me. Thank! > > > > 70 + 40 = 110 // first student (70 40 150) > > 110 + 15 = 125 //second one (99 15 400) > > 125 + 10 = 135 // third one (100 10 120), > > he is 15 min late, (he's to be free at 120) > > > > i hope it helps. > > > does this mean third should start at 110 and second start at > 110+10=120? students should start the exam as fast as they are ready (by the order of T1) so second student cannot enter the room after third one ( i suppose ;) ) if the input is 4 100 10 120 70 40 150 99 15 400 101 50 160 what's to output and why Solution: 1st) #2 starting at 70 ending at 110 2nd) #3 starting at 110 ending at 125 3rd) #1 starting at 125 ending at 135 (a +15 shift) 4th) #4 starting at 135 ending at 185 (a +25 shift) That way the answer should be 25 > if the input is > 4 > 100 10 120 > 70 40 150 > 99 15 400 > 101 50 160 > what's to output and why > if the input is > 4 > 100 10 120 > 70 40 150 > 99 15 400 > 101 50 160 > what's to output and why let's see 70 + 40 = 110 (70 40 150) 110 + 15 = 125 (99 15 400) 125 + 10 = 135 (100 10 120) 15 min late 135 + 50 = 185 (101 50 160) 25 min late if examenator shifts the beginning of the exam by 25 minutes then every student will pass the exam before T3.
> if the input is > 4 > 100 10 120 > 70 40 150 > 99 15 400 > 101 50 160 > what's to output and why Thank you hajime, I got AC. 70 + 40 = 110 // first student (70 40 150) 110 + 10 = 120 //second one (100 10 120) 129 + 10 = 139 // third one (99 15 400), he is free at 139? wait =0; > 70 + 40 = 110 // first student (70 40 150) > 110 + 10 = 120 //second one (100 10 120) > 129 + 10 = 139 // third one (99 15 400), > he is free at 139? > wait =0; Oleg i think thirs student comes in queue before second as his t1 is 99 and thirds is 100 agree? Thank all the people above! who can explain the problem? this problem is easy, A hint: If you have a square of 16 1*16 2*8 3..no, 3 no. 4*4... and that's all...just 3... Hope this help you! :) I understand now. Thank you very much! I also understand. Thank you. Thanks. Me understand too 8-) I see. Thanks! IC..THANKS My understands these good also. Tenk u for solveishn Yeah...it's a very clever hint Me too. Thx thank you very-very much! Let S4(n),S5(n),S6(n)- number of different 4-poligons,5-poligons and 6-poligons in n poligon. I have AC using formula F(n)=4*S4(n)+5*S5(n)+S6(n). But this formula can not be right because in different 6-poligons 3 hords may intersect in the same point and this triangle will be counted more the once. Your worry is superfluous This condition (put mentally n points on its periphery at equal distances) can guarantee that there will not be different 6-poligons 3 hords may intersect in the same point and this triangle will be counted more the once P.S My English is so poor... My suspictions based on considering ideal 12-poligon in which exist two ideal 6- sub-poligons which different and distinvished by rotation and having common centre in which their hord intersected. Edited by author 01.11.2007 22:26 I doubt anyone can mentally put 2000 points on a circle =) Hah, I on the other hand believe everyone can mentally (and not only) put infinitely many points on a circle. After all - isn't that the definition of a circle? (Infinitely many points with equal distance from one other point - the center?) :D F(n)=4*S4(n)+5*S5(n)+S6(n) Why is it true and how to guess about it? a picture is needed to understand ! please assist Yes, I was thinking about it too and I understand it now. In fact, it's said in statement that interesting triangle is not a triangle but "any three different chords from this set that intersect pairwise" and "at least one of their intersection points lies inside the circle". Therefore, three segments intersecting in one point are interesting triangle( and not a triangle). It's like saying that interesting triangle is a four-sided figure =) Answer is 1 1 But if A=1,P=1 A+P-1=1, so A+(A+P-1)=2 NOT 1?Am I wrong? The sequence is an arithmetic progression upto p terms. So, when n=1, only 1 term is required ie p=1. Hope you could understand. This is my code. It gets WA#7,but I cant find my mistake.Could you help,pls? #include<iostream.h> int main() { int n,i,j,s; cin>>n; if(n==1) { cout<<"1 1"; return 0; } if(n==2) { cout<<"2 1"; return 0; } for(i=1;i<=n/2;i++) { s=i; for(j=i+1;s<n;j++) s+=j; if(s==n) { cout<<i<<" "<<j-i; return 0; } } cout<<n/2<<" "<<1; return 0; } Maximum value of a is n not n/2. Your program gives wrong answer for n=4. Your output is 2 1 while correct one is 4 1. Thanks a lot,I passed WA,but now TLE #9.This algo is too slow :( try to manipulate this : N = P*(2A + (P-1))/2 N = input A & P = output loop P to find A Right answer for 1 is 0 2 not 1 0 !!! right answer is 1 1 , because 1=1+(1-1) ok i think this should be 2 2 Maximum value of a is n not n/2. Your program gives wrong answer for n=4. Your output is 2 1 while correct one is 4 1. To do calculations while [kx,ky] and [(k+1)x,(k+1)y] not intersect is very slow solution There is an O(1) solution. |
|