Общий форумdoes anybody knows what is this fucking test 5? if you know write the answer please:) sorry i've mistaked i've written knows instead of know type point=record x,y:longint; end; var vert:array[1..10000] of point; visited:array[1..10000] of byte; min:point; n,i,k,imin,minvert:integer; Procedure Search_Min_Polar_Angle; var i:integer; min_angle,angle,tg,a,b:real; begin min_angle:=pi; for i:=1 to n do if (visited[i]=0) then begin a:=(vert[i].y-vert[imin].y); b:=(vert[i].x-vert[imin].x); if (b=0) then angle:=pi/2 else begin tg:=a/b; angle:=arctan(tg); end; if (angle<min_angle) then begin min_angle:=angle; minvert:=i; end; end; visited[minvert]:=1; end; Begin readln(n); for i:=1 to n do visited[i]:=0;
// naxojdenie samoy nijney levoy to4ki min.y:=maxlongint; for i:=1 to n do begin readln(vert[i].x,vert[i].y); if (vert[i].y<min.y) then begin min:=vert[i]; imin:=i; end else if (vert[i].y=min.y) and (vert[i].x<min.x) then begin min:=vert[i]; imin:=i; end; end; visited[imin]:=1; //----------------------------------- for k:=1 to n div 2 do Search_Min_Polar_Angle; writeln(imin,' ',minvert); End. Edited by author 09.05.2010 19:47 It says: 17=2^4+2^0 18=2^4+2^1 20=2^4+2^2 But, since the limit is [15;20], 16 must also be included: 16=2^3+2^3 Create a code to determine the amount of integers, lying in the set [X;Y] and being a sum of exactly K different integer degrees of B. DIFFERENT degrees! I do not know why I am wrong, Netbeans works OK, but can not be accepted, below is my code. public class Main { public static void main(String[] args) { System.out.println("Addition of Two Numbers(a,b) the sum is c"); int a = Integer.parseInt(args[0]); int b = Integer.parseInt(args[1]); int c = a+b; System.out.println( "c="+c ); } } I do not know why I am wrong, Netbeans works OK, but can not be accepted, below is my code. public class Main { public static void main(String[] args) { System.out.println("Addition of Two Numbers(a,b) the sum is c"); // remove line int a = Integer.parseInt(args[0]);// use Scanner() to read numbers. Not console arguments. int b = Integer.parseInt(args[1]); int c = a+b; System.out.println( "c="+c );// your output must mutch with example's output. Just "System.out.println( c ); } } Dear Oleg Strekalovsky: Thank you so much for your help! Dear Oleg Strekalovsky: Due to your great help, my submission has finally been accepted. Thank you so much! thanks. answer me,plz this is a maths problem! you will do it as 1044 And 1036 but could you say it clearly? thank you. D[i,j,k] : i-th digit with the sum of 1st -> i-th digit = j and the difference between sum of even digits and sum of odd digits = k Result = Sum of D[n div 2,i,j] * D[n div 2,i,j] ; Understand ? No, can you explain it clearly ? Ha Ha! I think it's mostly the same as mine. But they're a little bit different. My Solution was 2 deminition DP. Use algorithm from problem #1036 my program variation: #include <stdio.h> #include <math.h> int main() { int nrstones, i, min, w1, w2; int *weights; scanf("%d", &nrstones); weights = new int[nrstones]; for(i = 0; i < nrstones; i++) { scanf("%d", &weights[i]); } min = weights[0]; int perm = 1 << nrstones; for(i = 0; i < perm; i++) { w1 = 0; w2 = 0; int j; for(j = 0; j < nrstones; j++) { if((i >> j) % 2 == 0) w1 += weights[j]; else w2 += weights[j]; } if(min > abs((double)w1 - w2)) { min = abs((double)w1 - w2); if(min == 0) { printf("%d", min); return 0; } } } printf("%d", min); return 0; } Edited by author 09.05.2010 11:37 Nice problem! To solve it your needto use the topological sort on the graph (DAG). It can be done with DFS algorithm. Actually I just sorted twice(one ascending and another one descending) and got AC. Your(compiler) idea is interesting, but not clear to me. Can you tell me your idea in details plz? You can also make this via e-mail: akshinioi@yahoo.com Edited by author 27.04.2005 21:52 VladG is right. It's the topological sort problem. See Cormen, Leiserson, Rivest, Stein "Introduction to algorithms" -> Elementary algorithms for graphs -> Topological sort The idea doesn't seem to be so clear. 2 10 4 100 14 266095289560 20 187019610394369600 Edited by author 09.05.2010 03:36 {$N+} var x, y, temp:extended; n, l, r, m, sum, res:extended; function rnd(t:extended):extended; begin if frac(t)>=0.5 then rnd:=trunc(t)+1 else rnd:=trunc(t); end; begin readln(x, y, n); l:=10; r:=10*n; x:=x*10; sum:=-1; while l<=r do begin m:=trunc((l+r)/2); temp:=rnd(m/n*10); if abs(temp-x)<10e-12 then begin sum:=m; l:=m+1; continue; end; if temp<x then l:=m+1 else r:=m-1; end; {writeln(sum:0:0);} if sum=-1 then begin writeln('Impossible'); exit; end; l:=0; r:=2000000000; res:=-1; while l<=r do begin m:=trunc((l+r)/2); temp:=(sum+m)/(n+m); if rnd(temp*10)<=y*10 then begin res:=m; r:=m-1; end else l:=m+1; end; if res=-1 then writeln('Impossible') else writeln(res:0:0); end. i think the compiler of this online judge still using old C.HINT,maybe u use comments notation of C++ ,this is , //. and declare it first before u use it . i sugest u use C++ compiler to submit the answer ,perhaps it will work. Кто знает 6 тест напишите пожалуйста Can it be solved using qsort+n*bs(on x coordinates of points) greetings You need to find a median in a sequence with ordering by polar angle. There are faster approaches. var x:array[1..20] of integer; y:array[1..20] of longint; min,s:longint; n,i,v:longint; procedure outit; var i:integer; s,c:longint; begin s:=0; for i:=1 to n do inc(s,x[i]*y[i]); c:=v-s; if c>s then s:=c-s else s:=s-c; if s<min then min:=s; end; procedure search(k:longint); var i:integer; begin if k>n then begin outit;exit;end; for i:=0 to 1 do begin x[k]:=i;search(k+1);end; end; begin readln(n); min:=0; v:=0; for i:=1 to n do read(y[i]); for i:=1 to n do begin min:=min+y[i]; end; v:=min; search(1); writeln(min); end. I think I'm right. program ural1005; var a:array[1..20]of boolean; w:array[1..20]of longint; i,j,k,n,m:longint; function dif:longint; var diff:longint; begin diff:=0; for i:=1 to n do if a[i] then inc(diff,w[i]) else dec(diff,w[i]); exit(diff); end; procedure dfs(i:longint); begin if i>n then begin if abs(dif)<m then m:=abs(dif); exit; end; a[i]:=true; dfs(i+1); a[i]:=false; dfs(i+1); end; begin readln(n); for i:=1 to n do readln(w[i]); m:=maxlongint; a[1]:=true; dfs(2); writeln(m); end. Me too not readln(w[i]); but read(w[i]); I had this mistake at the first time (because of spaces between numbers) I don't know how could i choose next point. I have some ideas about it: 1. The solution isn't very complexity(maybe it uses sorting) 2. I think, Elephpotamus always can eat all pumpkins 3. And our path should be spin or smth like it. Help plz It's nice and easy problem 1) find the point witch min Y 2) build angles 3) sort angles 4) print answer. What angles should I built? Between (a[1],a[ymin]) and (a[ymin],a[i])? A(Point[i].X, Point[i].Y) B(Ymin.X, Ymin.Y) C(Point[i].X, Ymin.Y) I have <...> as result of doing this task. I think it's terrible. Help me more. I don't know what kind of mistake I have... WA8 is terrible Edited by author 01.04.2006 04:49 If you want I can send my solution! My e-mail: Pio@mail.by I used idea of solution to problem 1173 with some updates: At 1173: "No 3 points on the same straight line" At 1444: "Not all points on the same straight line". Try tests, were some points are on the same straight line. My WA solution breaks on the same tests. I WA at Test 4. Who can tell me what the test 4 is? Edited by author 04.04.2010 10:48 I also wonder. Used sorting just like in 1203 - and can't understand a fault. The following case suddenly cracked my program: 5 0 100 1 2 2 3 3 4 4 5 Though sorting still rules. Edited by author 06.05.2010 00:50 what if in one way we can reach , but on opposite way we can't? for example,what is output for this test? input: 0 3 Your test is incorrect, such case is impossible. It is guaranteed that 1D person will encounter either obstacle or exit point sooner or later regardless of the initial direction. you mean...such test is not exceed?...or i must output "impossible" when n is equal to you mean...such test is not exceed?...or i must output "impossible" when n is equal to zero There are no such tests. but what is test 13?i got wrong answer in test 13... program temp; var a:array [1..1000000] of qword; i,m:longint; begin while not eof do begin inc(i); read(a[i]); end; for m:=i downto 1 do writeln(sqrt(a[m]):0:4); end. What's the problem? 为何#1就不过? Edited by author 05.05.2010 19:51 Must we perform the quests in the same order, that they were listed in input? The quests can be performed in а different order. All quests are performed as soon as they can be performed. If there are several quests available, the one that was received earlier is performed first. #include <stdio.h> int main() { int n1,c1,n2,t,c2,n3,k,i; scanf("%d %d",&n1,&c1); scanf("%d %d %d",&n2,&t,&c2); scanf("%d",&n3); scanf("%d",&k); int (*A)[2] = new int[k][2]; for( i=0; i<k; ++i ) { scanf("%d:%d",&A[i][0],&A[i][1]); } int basic = n1,combined = n2,unlimited = n3,bas=0,com=0;
for( i=0; i<k; ++i ) { if(A[i][0]!=0) { bas+=A[i][0]; com+=A[i][0]; } if( (A[i][0]==0 && A[i][1]>6) || (A[i][0]!=0 && A[i][1]!=0 ) ) { ++bas; ++com; } } if ( com>t ) { com-=t; com*=c2; } bas *= c1; basic += bas; combined += com;
printf("Basic: %d\n",basic); printf("Combined: %d\n",combined); printf("Unlimited: %d\n",unlimited); delete [] A; return 0; } Test: 135 1 220 10 1 300 5 00:05 00:10 00:59 05:00 01:01 Answer: Basic: 144 Combined: 220 Unlimited: 300 Combined in this test must be 221... because 00:10 gives 1 minute , 00:59 give 1 minute , 05:00 gives 5, 01:01 gives 2...or... 01:01 gives 1 minute or 2 minutes ?? 00:10 - 1 minute; 00:59 - 1 minute; 05:00 - 5 minutes; 01:01 - 2 minutes. All time is 9 minutes. In this test you are allowed to talk up to 10 minutes per month for free. You talked only 9. So you should pay only monthly fee - 220. Yes , thanks . I should write [ else com=0 ] after [ if(com > t){...} ] |
|