Общий форумhere is my code. please help me :(( #include <stdio.h> #define HMAX (1<<17) int N; unsigned int H[HMAX]; void sift(int x) { int aux, up = x>>1; if (x < 1) return; if (H[x] > H[up]) { aux = H[x]; H[x] = H[up]; H[up] = aux; sift(up); } } void perc(int x, int n) { int l = x<<1, r = (x<<1)+1, max, aux; if (r > n) return; max = l; if (H[l] < H[r]) max = r; if (H[max] > H[x]) { aux = H[max]; H[max] = H[x]; H[x] = aux; perc(max, 1+N/2); } } int main() { int i, val; long double sol; unsigned int last, blast; // freopen("1306.in", "r", stdin); scanf("%d", &N); H[0] = 4294967295; for (i = 1; i <= 1+(N/2); i++) scanf("%lu", H+i); for (i = 1; i <= 1+(N/2); i++) sift(i); for (i = 2+(N/2); i <= N; i++) { scanf("%d", &val); if (val < H[1]) { H[1] = val; perc(1, 1+(N/2)); } } blast = H[1]; H[1] = 0; perc(1, (N/2)); last = H[1]; sol = last*0.5; sol += blast*0.5; if ( (N&1) == 0 ) printf("%0.1llf\n", sol); else printf("%u\n", blast); return 0;
} please help me Try test with n=2. FE 2 10 20 The result of my Program is 15.0 How about you ?? In my opinion, test #2 contain data like this: 1 5 Correct answer is: 5.0 I had a problem with output format. We should output the answer with one decimal digit after decimal point. My wrong program had written: 5 without fractional part. from the betting coefficient k is (m + n) / n I think k must be greater than 1. Don't you think so? What is test 6? Edited by author 11.01.2013 21:21 Can somebody give test #16? Getting TLE Thnx when you search x and y (A*x+B*y = N) use something like this for x:= 0 to min(n div a, trunc(sqrt(n))) do =) if stones are sorted then answer is n-1 It took me a while to find out this special case :) this is very bad problem :( Try the following test: 50 3081 30488 b 16217 39416 w 7248 11364 w 17676 32492 w 25292 30974 w 1686 28199 w 9576 25807 w 18823 21457 w 30775 38642 w 7758 15847 b 6289 19805 b 1546 26246 w 27602 30148 w 9296 14836 w 19435 26471 w 27882 35227 w 24453 42158 w 943 1752 b 4080 12268 w 31529 41419 w 6238 22445 w 6262 13797 w 16616 31697 w 9990 12426 w 31675 46085 w 15149 32698 b 16029 18700 b 32372 50450 w 19642 25152 b 21096 30699 b 27244 35134 b 29951 43374 w 8869 9499 w 3375 28256 w 2060 14099 b 19972 37822 b 30222 33297 b 5433 9482 w 28735 54469 b 19053 31004 w 12234 27889 b 19117 19750 b 11927 17069 w 30056 32152 b 21756 25680 w 25656 44214 b 5308 18661 b 21710 26158 b 9196 32476 b 9917 11034 b I don't know what the output is. Mine was 54496 1000000000 Nice to see, but "higher" relation is not transitive ;-) It is very easy problem, but why only 54 people solved?! This problem has simple solution and very interesting, but not obvious idea... can anybody explain me how to use reals with big range like 10^18 or 10^19 more precisely in pascal? If you need real numbers with best affordable precision - use long double ("extended" in pascal). Edited by author 06.01.2013 23:12 I knew the solution was k=1 or trunc((1+12*b*b/(a*a)-3*c/a)). but i could not take precision. If you need real numbers with best affordable precision - use long double ("extended" in pascal). F**k, spoiler =( Then you don't need real numbers here - long long (int64 in Pascal) is enough to solve it Please help Why am I getting floating-point invalid operation on test 3? Would it be possible to see the test values? program pr_1; var n, i, x: longint; a: real; begin read(n); for i:=1 to n do begin read(x); a:= (1 + sqrt(8*x-7))/2; if (Frac(a) = 0.0) then write('1 ') else write('0 '); end; end. program acm_1130; type vec=record x,y:longint; end; var w,a:array[1..3]of vec; c,b:vec; i,n,nn:longint; L:longint; p:array[0..10000,1..3,1..2] of byte; q:array[0..10000,1..3]of shortint; f:boolean; procedure delta(nn,r:longint); var j:longint; begin if nn=0 then exit; for j:=1 to 2 do if p[nn,r,j]>0 then begin q[nn-1,p[nn,r,j]]:=-q[nn-1,p[nn,r,j]]; delta(nn-1,p[nn,r,j]); end; end; procedure minn(i:longint); begin if sqr(a[1].x+a[2].x)+sqr(a[1].y+a[2].y)<=sqr(L) then begin w[1].x:=a[1].x+a[2].x; w[1].y:=a[1].y+a[2].y; w[2]:=a[3]; q[i,1]:=1; q[i,2]:=1; q[i,3]:=1; p[i+1,1,1]:=1; p[i+1,1,2]:=2; p[i+1,2,1]:=3; exit; end; if sqr(a[1].x-a[2].x)+sqr(a[1].y-a[2].y)<=sqr(L) then begin w[1].x:=a[1].x+a[2].x; w[1].y:=a[1].y+a[2].y; w[2]:=a[3]; q[i,1]:=1; q[i,2]:=-1; q[i,3]:=1; p[i+1,1,1]:=1; p[i+1,1,2]:=2; p[i+1,2,1]:=3; exit; end; if sqr(a[1].x+a[3].x)+sqr(a[1].y+a[3].y)<=sqr(L) then begin w[1].x:=a[1].x+a[3].x; w[1].y:=a[1].y+a[3].y; w[2]:=a[2]; q[i,1]:=1; q[i,2]:=1; q[i,3]:=1; p[i+1,1,1]:=1; p[i+1,1,2]:=3; p[i+1,2,1]:=2; exit; end; if sqr(a[1].x-a[3].x)+sqr(a[1].y-a[3].y)<=sqr(L) then begin w[1].x:=a[1].x-a[3].x; w[1].y:=a[1].y-a[3].y; w[2]:=a[2]; q[i,1]:=1; q[i,2]:=1; q[i,3]:=-1; p[i+1,1,1]:=1; p[i+1,1,2]:=3; p[i+1,2,1]:=2; exit; end; if sqr(a[2].x+a[3].x)+sqr(a[2].y+a[3].y)<=sqr(L) then begin w[1].x:=a[2].x+a[3].x; w[1].y:=a[2].y+a[3].y; w[2]:=a[2]; q[i,1]:=1; q[i,2]:=1; q[i,3]:=1; p[i+1,1,1]:=2; p[i+1,1,2]:=3; p[i+1,2,1]:=1; exit; end; if sqr(a[2].x-a[3].x)+sqr(a[2].y-a[3].y)<=sqr(L) then begin w[1].x:=a[2].x-a[3].x; w[1].y:=a[2].y-a[3].y; w[2]:=a[2]; q[i,1]:=1; q[i,2]:=1; q[i,3]:=-1; p[i+1,1,1]:=2; p[i+1,1,2]:=3; p[i+1,2,1]:=1; exit; end; end; begin read(n); read(L); if n=1 then begin write('+'); exit; end; if n=2 then begin read(c.x,c.y); read(b.x,b.y); if sqr(c.x-b.x)+sqr(c.y-b.y)<sqr(c.x+b.x)+sqr(c.y+b.y) then writeln('+-') else writeln('++'); exit; end; for i:=1 to 3 do read(a[i].x,a[i].y); fillchar(p,sizeof(p),0); fillchar(q,sizeof(q),1); minn(0); a[1]:=w[1]; a[2]:=w[2]; for i:=1 to n-3 do begin read(a[3].x,a[3].y); minn(i); a[1]:=w[1]; a[2]:=w[2]; end; f:=true; if sqr(a[1].x-a[2].x)+sqr(a[1].y-a[2].y)<sqr(a[1].x+a[2].x)+sqr(a[1].y+a[2].y) then f:=true else f:=false; if f then begin nn:=n-2; delta(nn,2); end; writeln('YES'); for i:=1 to 3 do if q[0,i]>0 then write('+') else write('-'); for i:=1 to n-3 do if q[i,3]>0 then write('+') else write('-'); end. Edited by author 07.01.2013 14:31 What is special about this problem? I get WA 7 all the time. My algo [code deleted] Edited by author 01.01.2013 16:44 Edited by author 01.01.2013 20:16 Edited by author 01.01.2013 20:18 Edited by moderator 29.11.2019 14:27 I found the error, it was not the algo. It was in the routine to find the maximum. The algo is perfect. #include<iostream> #include<string> using namespace std; int main(){ int line=1,liner,start=0,paper=1,word,symbol; cin>>liner>>symbol>>word; for(int i=0;i<word;i++){ string s; cin>>s; int a; if(start==0) a=s.size(); else a=s.size()+1; if((start+a)<symbol) start=start+a; else { start=0; line++;} } if(line%liner==0) cout<<(line/liner); else cout<<(line/liner+1); system("pause"); return 0; } why the answer to the first sample is 2 I THANK IT IT 1 because let x=1 then f(x)=0 so it only takes 1 sec I misunderstood the statement. That is it? Help For example :) 1 -5 5 Answer *....| .....| .....| .....| .....| -----+ Thank you. I pass this test and now I get WA16 (= Отослал написано Accepted, но в рейтинге стоит вопросик, хотя система засчитала правильный ответ. Так и должно быть? What's wrong with 33th test?)) Or what reazons to access violation? And my IDE write correct answer - 31861500 if N=1 000 000 000 i have Q->555555555888. And as i read it's right answer. Edited by author 06.01.2013 05:07 how to get a 0.19 in the first test ? what formula ? What is it? Edited by author 05.01.2013 17:57 Edited by author 05.01.2013 17:57 |
|