Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | Help!Why I always get WA? | Bighead | 1048. Сверхдлинные суммы | 9 май 2002 06:55 | 6 | I think my program is correct,but it always gets WA,why? Here is my program: program U1048; const digits=100000000; var n1,n2:array[0..200000] of longint; i,j,n,a,b:longint; s:string; begin readln(n); n1[0]:=0; for j:=n div 8*8+1 to n do begin readln(a,b); n1[1]:=n1[1]*10+a; n2[1]:=n2[1]*10+b; end; inc(n1[1],n2[1]); for i:=1 to n div 8 do begin for j:=1 to 8 do begin readln(a,b); n1[i+1]:=n1[i+1]*10+a; n2[i+1]:=n2[i+1]*10+b; end; inc(n1[i+1],n2[i+1]); end; for i:=n div 8+1 downto 1 do if n1[i]>=digits then begin dec(n1[i],digits); inc(n1[i-1]); end; j:=0; while (n1[j]=0)and(j<200000) do inc(j); if n1[j]=0 then writeln(0) else begin write(n1[j]); for i:=j+1 to n div 8+1 do begin str(n1[i],s); while length(s)<8 do s:='0'+s; write(s); end; writeln; end; end. Oh, my god!You uses Array? Can you pass the Memory Limited? Maybe you can but you needn't use it at all.:( I'm so sorry that I can't understand you program at all. but If you want ,I'll give you some hint. Give up in this way.OK? In my program, I use a longint to save 8 digits, so I can pass the memory limit easily, but it always get WA, I really don't know why. > 1 > 0 0 > > your answer - 1 But on my pc my answer is 0.Why? > > 1 > > 0 0 > > > > your answer - 1 > > But on my pc my answer is 0.Why? i don't know. i've use turbo pascal 7.0 ... and, if this test correct. 2 0 0 1 1 your answer is 2 (on my pc ;) ) but your must output 02. | | Please check it, I think it's simple | raxtinhac | 1195. Крестики-нолики | 8 май 2002 19:33 | 1 | const fi = '1195.inp'; max = 3; so = 8; line :array[1..so,1..3,1..2] of byte =( ( (1,1), (1,2), (1,3) ), ( (2,1), (2,2), (2,3) ), ( (3,1), (3,2), (3,3) ), ( (1,1), (2,1), (3,1) ), ( (1,2), (2,2), (3,2) ), ( (1,3), (2,3), (3,3) ), ( (1,1), (2,2), (3,3) ), ( (1,3), (2,2), (3,1) ) ); var a,b :array[1..3,1..3] of char; kq :byte; procedure input; var f :text; i,j :byte; st :string; begin {assign(f, fi); reset(f);} for i := 1 to 3 do begin readln({f}, st); while st[1] = ' ' do delete(st,1,1); while st[ length(st) ] = ' ' do delete(st, length(st), 1); for j := 1 to 3 do a[i,j] := st[j]; end; {close(f);} end; procedure out; begin case kq of 0 : writeln('Draw'); 1 : writeln('Crosses win'); 2 : writeln('Ouths win'); end; end; function thang :boolean; var i,j :byte; c :char; ok :boolean; begin thang := true; for i := 1 to so do begin ok := true; c := b[ line[i,1,1], line[i,1,2] ]; if c = '#' then ok := false; for j := 1 to 3 do if b[ line[i,j,1], line[i,j,2] ] <> c then ok := false; if ok then exit; end; thang := false; end; function cross :boolean; var i,j :byte; begin cross := true; for i := 1 to 3 do for j := 1 to 3 do if a[i,j] = '#' then begin b := a; b[i,j] := 'X'; if thang then begin kq := 1; exit; end; end; cross := false; end; procedure outh; var i,j,u,v :byte; ok :boolean; begin for i := 1 to 3 do for j := 1 to 3 do if a[i,j] = '#' then begin b := a; b[i,j] := 'X'; ok := false; for u := 1 to 3 do for v := 1 to 3 do if b[u,v] = '#' then begin b[u,v] := 'O'; if thang then ok := true; b[u,v] := '#'; end; if not ok then exit; end; kq := 2; end; procedure solve; begin kq := 0; if cross then exit; outh; end; begin input; solve; out; end. | | Labyrinth problem. | I.J. Matrix | | 8 май 2002 00:26 | 1 | Why compilation error? On my Borland Pascal everything is fine, but Judge system doesn't like my source. | | Почему у меня не работает п
 | Yuriy Frolov (ufrolov@ukr.net) | 1081. Двоичная последовательность | 7 май 2002 23:37 | 1 | | | Huge | Hagea Silviu | | 7 май 2002 20:43 | 2 | Huge Hagea Silviu 7 май 2002 05:03 Huge is not accepted in C? Why I get compilation error? | | Why I got wrong? | qwt | 1118. Нетривиальные числа | 7 май 2002 09:17 | 1 | const ss:array[1..169] of longint=( 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71, 73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167 ,173, 179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,27 1,277,281, 283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,39 7,401,409, 419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,52 1,523,541, 547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,64 7,653,659, 661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,78 7,797,809, 811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,92 9,937,941, 947,953,967,971,977,983,991,997,0); var a:array[1..169] of longint; i,j,k,x,y:longint; function judge(m:longint):boolean; var i,j,k,n,q:longint; begin n:=m; fillchar(a,sizeof(a),0); judge:=false; i:=1; while (n>1)and(i<169) do begin while n mod ss[i]=0 do begin inc(a[i]); n:=n div ss[i]; end; inc(i); end; if n>1 then begin ss[169]:=n;a[169]:=1;end; k:=1; for i:=1 to 169 do if a[i]>0 then begin q:=1; for j:=1 to a[i] do q:=q*ss[i]+1; if m*2<k*q then exit; k:=k*q; end; judge:=true; end; begin readln(x,y); for i:=x to y do if judge(i) then begin writeln(i);break;end; end. | | What wrong with my program? Please help me... | Evgeny Reshetnikov | 1085. Встреча | 6 май 2002 22:04 | 1 | Program n1085; Const MaxN = 100; MaxM = 100; MaxK = 100; Var n,m,k,step : integer; i,j,q,w : integer; money : array [1..MaxK] of integer; a : array [1..MaxM,1..MaxN] of byte; b : array [1..MaxK,1..MaxN] of Record sum : integer; step,t : byte; End; lost,num : longint; Procedure Init; Var stop,l : byte; sum : integer; Begin Read(n,m); FillChar(a,SizeOf(a),0); For i:=1 to m Do Begin Read(l); For j:=1 to l Do Begin Read(stop); a[i,stop]:=1; End; End; Read(k); For i:=1 to k Do For j:=1 to n Do Begin b[i,j].sum:=0; b[i,j].step:=0; b[i,j].t:=0; End; For i:=1 to k Do Begin Read(sum,stop,l); money[i]:=sum; b[i,stop].sum:=sum; b[i,stop].step:=1; b[i,stop].t:=l; End; End; Procedure Solve; Var yes : boolean; Begin step:=1; While true Do Begin yes:=true; For i:=1 to k Do For j:=1 to n Do If (b[i,j].step=step) and (b[i,j].sum>=4) Then Begin yes:=false; For q:=1 to m Do If a[q,j]=1 Then For w:=1 to n Do If (a[q,w]=1) and (b[i,w].step=0) Then Begin b[i,w].step:=step+1; b[i,w].t:=b[i,j].t; If b[i,j].t=0 Then b[i,w].sum:=b[i,j].sum-4 Else b[i,w].sum:=b[i,j].sum; End; End; If yes Then Break; step:=step+1; End; End; Procedure SearchAns; Var yes : boolean; los : longint; Begin lost:=MaxLongInt; num:=0; For i:=1 to n Do Begin yes:=true; los:=0; For j:=1 to k Do If b[j,i].step=0 Then Begin yes:=false; Break; End Else los:=los+money[j]-b[j,i].sum; If yes and (los<lost) Then Begin lost:=los; num:=i; End; End; End; Procedure WriteIt; Begin If num<>0 Then Write(num,' ',lost) Else Write('0'); End; Begin Init; Solve; SearchAns; WriteIt; End. | | HELP ME PLEASE ~!~!I GOT WA AGAIN | bingo2002 | 1106. Две команды | 6 май 2002 21:08 | 1 | type info=record fri:array[1..101]of integer; no:integer; count:integer; end; label endof, endla; var n,sum,i,j:integer; node:array[1..100]of info; temp:integer; begin assign(input,'input.txt'); assign(output,'output.txt'); readln(input,n); for i:=1 to n do begin read(input,temp); j:=1; while temp<>0 do begin node[i].fri[j]:=temp; inc(j); read(input,temp); end; dec(j); node[i].count:=j; node[i].no:=0; if j=0 then goto endof; readln; end; sum:=0; node[1].no:=1; inc(sum); for i:=1 to node[1].count do node[node[1].fri[i]].no:=2; for i:=2 to n do begin if node[i].no<>2 then begin node[i].no:=1; inc(sum); for j:=1 to node[i].count do node[node[i].fri[j]].no:=2; end; end; writeln(output,sum); for i:=1 to n do begin if node[i].no=1 then begin write(output,i); write(output,' '); end; end; goto endla; endof: write(output,0); endla: { TODO -oUser -cConsole Main : Insert code here } end. | | now its me... HELP ME | Edans | 1207. Медиана на плоскости | 30 апр 2002 09:01 | 1 | somebody see a mistake? #define MAXINT 2000000000 #include<stdio.h> #include<math.h> #include<stdlib.h> typedef struct{ int x,y; int ID; double ang; }ponto_t; ponto_t tb[10000]; int sort( const void *a, const void *b){ ponto_t* ta = (ponto_t*)a; ponto_t* tb = (ponto_t*)b; if ((ta->x==0) && (ta->y==0)) return -1; if ((tb->x==0) && (tb->y==0)) return 1; return (ta->x*tb->y - tb->x*ta->y)>0?1:-1; } int main(){ #ifndef ONLINE_JUDGE freopen("1207.in","r",stdin); freopen("1207.out","w",stdout); #endif int n,x=MAXINT,themin=0,k; scanf("%d",&n); for(k=0;k<n;k++){ scanf("%d %d",&(tb[k].x),&(tb[k].y)); tb[k].ID=k+1; if (tb[k].x<x){ x=tb[k].x; themin=k; } } for(k=0;k<n;k++){ tb[k].x-=tb[themin].x; tb[k].y-=tb[themin].y; } qsort(tb,n,sizeof(ponto_t),sort); printf("%d %d",tb[0].ID,tb[n/2].ID); return 0; } | | why i got WA??? | bingo2002 | 1106. Две команды | 29 апр 2002 23:06 | 1 | type info=record link:array[1..100]of integer; position:integer; count:integer; end; label 99; var n,i,j,temp,sum:integer; a:array[1..100]of info; begin {assign(input,'input.txt'); assign(output,'output.txt'); rewrite(output); reset(input); } readln(n); for i:=1 to n do begin read(temp); j:=0; while temp<>0 do begin a[i].link[j]:=temp; inc(j); read(temp); end; dec(j); a[i].count:=j; if a[i].count=0 then goto 99; a[i].position:=0; readln; end; a[1].position:=1; sum:=1; for i:=1 to a[1].count do a[a[1].link[i]].position:=2; for i:=2 to n do begin if a[i].position=0 then begin a[i].position:=1; inc(sum); for j:=1 to a[i].count do a[a[i].link[j]].position:=2; end; end; writeln(sum); writeln(output,sum); for i:=1 to n do if a[i].position=1 then begin write(i); write(' '); end; {close(input); close(output);} 99: writeln(0); readln; end. | | Can anyone explain me why should I ignore branches with 0 apples ? | Szasz Pal | 1018. Двоичная яблоня | 29 апр 2002 22:24 | 1 | If I ignore the branches with 0 apples (but why ?!) then I won't get a BINARY tree ! Please, somebody, explain me. | | I don't know why I got WA? | qwt | 1153. Суперкомпьютер | 29 апр 2002 19:29 | 1 | type num=array[0..10000] of longint; function max(a,b:longint):longint; begin if a>b then max:=a else max:=b; end; procedure chen(x:num;y:longint;var ans:num); var i,j,k:longint; begin fillchar(ans,sizeof(ans),0);ans[0]:=1; if y=0 then exit; for i:=1 to x[0] do begin inc(ans[i],x[i]*y); if ans[i]>=100 then begin ans[i+1]:=ans[i] div 100; ans[i]:=ans[i] mod 100; end; end; if ans[i+1]>0 then ans[0]:=i+1 else ans[0]:=i; end; procedure plus(x,y:num;var ans:num); var i:longint; begin fillchar(ans,sizeof(ans),0); for i:=1 to max(x[0],y[0]) do begin inc(ans[i],x[i]+y[i]); if ans[i]>=100 then begin ans[i+1]:=ans[i] div 100; ans[i]:=ans[i] mod 100; end; end; if ans[i+1]>0 then ans[0]:=i+1 else ans[0]:=i; end; function bigger(x,y:num):longint; var i:longint; begin bigger:=0; if x[0]>y[0] then begin bigger:=1;exit;end else if x[0]<y[0] then begin bigger:=-1;exit;end; for i:=x[0] downto 1 do if x[i]>y[i] then begin bigger:=1;exit;end else if x[i]<y[i] then begin bigger:=-1;exit;end; end; procedure minus(x,y:num;var ans:num); var i,j,k:longint; begin fillchar(ans,sizeof(ans),0); for i:=1 to x[0] do begin inc(ans[i],x[i]-y[i]); if ans[i]<0 then begin inc(ans[i],100);dec(ans[i+1]);end; end; ans[0]:=i; while (ans[0]>1)and(ans[ans[0]]=0) do dec(ans[0]); end; procedure work(x:num); var i,j,k,y:longint; a,b,c,d:num; begin fillchar(a,sizeof(a),0);a[0]:=1;b:=a;c:=a; a[1]:=2*trunc(sqrt(x[x[0]])); c[2]:=x[x[0]]-sqr(a[1] div 2);c[1]:=x[x[0]-1]; write(a[1] div 2); if c[2]=0 then c[0]:=1 else c[0]:=2; for i:=x[0]-1 downto 1 do begin chen(a,10,a); for y:=9 downto 0 do begin fillchar(b,sizeof(b),0);b[0]:=1; b[1]:=y; plus(a,b,b); chen(b,y,b); if bigger(c,b)>=0 then break; end; write(y); minus(c,b,c); fillchar(d,sizeof(d),0);d[0]:=1;d[1]:=y*2; plus(a,d,a); for j:=c[0] downto 1 do c[j+1]:=c[j];inc(c[0]); c[1]:=x[i-1]; while (c[0]>1)and(c[c[0]]=0) do dec(c[0]); end; writeln; end; var a:num; i,j,k:longint; z:char; l:array[0..5000] of longint; begin k:=0; while not(eoln) do begin read(z); inc(k); l[k]:=ord(z)-ord('0'); end; a[0]:=0; for i:=1 to (k+1) div 2 do a[i]:=l[k-i*2+2]+10*l[k-i*2+1]; a[0]:=(k+1) div 2; chen(a,2,a); work(a); end. | | I am very sorry that you can proceduce 0 Horn and 0 Hoof! | ECUST kinglions | 1200. Рога и копыта | 29 апр 2002 11:06 | 2 | I am very sorry that you can proceduce 0 Horn and 0 Hoof! sorry,but i don't think so. i've seen an ac problem,and it allows 0 0 | | why i got wrong answer? | qwt | 1118. Нетривиальные числа | 28 апр 2002 19:30 | 1 | var z,y,x,a,b,tt,i,j,k,p,q,r:longint; ss:array[1..10000] of longint; s:string; begin tt:=1;ss[1]:=2; for i:=3 to trunc(sqrt(1000000)) do begin for j:=1 to tt do if (i mod ss[j]=0)or(ss[j]>trunc(sqrt(i))) then break; if i mod ss[j]<>0 then begin inc(tt); ss[tt]:=i; end; end; readln(a,b); for y:=a to b do begin q:=1; x:=y; r:=1; k:=1; while (x<>1 )and(k<>tt) do begin for j:=k to tt do if x mod ss[j]=0 then break; k:=j; if x mod ss[j]=0 then begin z:=1; p:=1; while x mod ss[j]=0 do begin z:=z*ss[j]; p:=z+p; q:=q*ss[j]; x:=x div ss[j]; end; r:=r*p; if (r>=2*q) then break; end; end; if x<>1 then begin r:=r*(x+1);q:=y;end; if r<2*q then begin
writeln(y); halt; end; end; end. | | Some strange things about the end of file. | Song Chao (ECUST Mutistar) | 1027. Снова D++ | 28 апр 2002 17:02 | 1 | I just have passed this problem, but I find some strange thing. I use pascal language, and I used 'Ch=EOF' to judge the end of file in this problem. And I always got WA. After reading some other codes, I changed this line to 'Ch=#26', and got AC. I don't know why. | | Help. My program always got Wrong Answer! | crazy | 1030. Титаник | 28 апр 2002 00:50 | 4 | Maybe the input is wrong but i don't know how to do this help thanks ! #include<iostream.h> #include<math.h> #include<stdio.h> const double pi=3.1415926; const double R=3437.5; double x_ship,y_ship,z_ship; double x_ice,y_ice,z_ice; double dist(double x1,double y1,double z1,double x2,double y2,double z2) { double ans; ans=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)); return ans; } void main() { double X1,X2,X3,Y1,Y2,Y3; double A1,A2,A3,B1,B2,B3; double ans,sita,d,r1,r2; int location_ship1,location_ship2,location_ice1,location_ice2; char ch[200]; char c; //north=1;south=-1;east=1;west=-1; //input gets(ch); gets(ch); gets(ch); cin>>X1>>c>>X2>>c>>X3>>c>>ch; if(ch[0]=='N') location_ship1=1; else location_ship1=-1; cin>>ch>>Y1>>c>>Y2>>c>>Y3>>c>>ch; if(ch[0]=='E') location_ship2=1; else location_ship2=-1; gets(ch); cin>>A1>>c>>A2>>c>>A3>>c>>ch; if(ch[0]=='N') location_ice1=1; else location_ice1=-1; cin>>ch>>B1>>c>>B2>>c>>B3>>c>>ch; if(ch[0]=='E') location_ice2=1; else location_ice2=-1; gets(ch);
z_ship=R*sin((X1+(X2+X3/60)/60)*pi/180); z_ship*=location_ship1; r1=R*cos((X1+(X2+X3/60)/60)*pi/180); z_ice=R*sin((A1+(A2+A3/60)/60)*pi/180); z_ice*=location_ice1; r2=R*cos((A1+(A2+A3/60)/60)*pi/180); y_ship=r1*cos((Y1+(Y2+Y3/60)/60)*pi/180); y_ice=r2*cos((B1+(B2+B3/60)/60)*pi/180); x_ship=r1*sin((Y1+(Y2+Y3/60)/60)*pi/180); x_ship*=location_ship2; x_ice=r2*sin((B1+(B2+B3/60)/60)*pi/180); x_ice*=location_ice2; d=dist(x_ship,y_ship,z_ship,x_ice,y_ice,z_ice); sita=acos((R*R*2-d*d)/(2*R*R)); ans=R*sita; printf("The distance to the iceberg: %.2lf miles. \n",ans); if(ans<100) printf("DANGER!\n"); } Your program prints DANGER if the answer is 99.999999; you should print DANGER only if the number you have printed is 99.99 or less Good luck. thank you but i could not correct my program and i still got the wrong answer whether you can tell me more also i doubt whether my input code is ok? i am so lazy and i do in this way Well, you could see how many symbols you have printed (i think printf returns this), so if this number is ... (one more than usually), you print 'DANGER!' Good luck. | | Can someone look at this? | Crytcheck | 1116. Кусочно-постоянная функция | 27 апр 2002 17:14 | 1 | Hi, i've got a little bit diffrent alg. than 'normal' one. array[- 32000..32000], where i mark begining and ends of interval. than just searching all table and write the output. i can't find any test, where my prog. doesn't work, but i still have wrong answer. here's my code: type twartosc=record val:shortint; p1,p2,k1,k2:boolean; end; var tab:array[-32000..32000] of twartosc; n,p,i,k,w,j:integer; o1,o2:boolean; {is F1 and F2 definned with given argument?) begin read(n); if n=0 then begin write(0); exit; end; for i:=1 to n do begin read(p); read(k); read(w); for j:=p to k do tab[j].val:=w; tab[p].p1:=true; tab[k].k1:=true; {reading F1 and mark it in array} end; readln; read(n); if n<>0 then for i:=1 to n do begin read(p); read(k); read(w); tab[p].p2:=true; tab[k].k2:=true; {the same with F2 (it's value isn't nedded)} end; j:=0; {let j tell us about number of intervals of output function} for i:=-32000 to 32000 do begin if (tab[i].k1) then o1:=false; {close F1} if (tab[i].p2) then o2:=true; {open F2} if tab[i].k2 then begin if o1 then inc(j); {if F1 is opened and we're closing F2, new interval is begging} o2:=false; end; if tab[i].p1 then begin if not o2 then inc(j); {similar to prev} o1:=true; end; end; write(j,' '); {write number of intervals, and now we're seeking for them} for i:=-32000 to 32000 do begin if (tab[i].k1) then begin o1:=false; if not o2 then write(i,' ',tab[i].val,' '); end; if (tab[i].p2) then begin o2:=true; if (o1) and (not tab[i].k2) then write(i,' ',tab [i].val,' '); end; if tab[i].k2 then begin if (o1) and (not tab[i].p2) then write(i,' '); o2:=false; end; if tab[i].p1 then begin if not o2 then write(i,' ');; o1:=true; end; end; end. | | Complexity | HELLER | 1153. Суперкомпьютер | 27 апр 2002 00:06 | 1 | It's very strange that my program has got AC (It has worked for ~3 sec). I've been founding answer with binary search ! :)) If you have really fast solution, please, send it on _my_inbox@mail.ru | | Why I get Compile Error on P1131. Help, please!!! | meoden | | 26 апр 2002 07:11 | 1 | Help!!! This code get Compile Error. Tell me why, pls! var n,k,s,t:longint; begin read(n,k); s:=1; t:=0; for t:=1 to 31 do begin s:=s*2; if s>n then break; if s>k then begin t:=t+(n-s+k-1) div k; break; end; end; writeln(t); end. | | n^1.5 algorythm | HELLER | 1108. Наследство | 26 апр 2002 01:11 | 1 | Can anyone send me such algorythm (or post url for related info) for multiplying big nums? _my_inbox@mail.ru I heard about n*log(n), but never about n^1.5... I've solved 1108 with standard n*m complexity without any optimizing with time ~ 2.5 sec, but i want 0.05 sec without any precomputations :) . Also, I guess where is some law in digits order of the numbers, wich can help to compute each number for O(n). |
|
|