Common Board Edited by author 11.10.2008 23:11 {$APPTYPE CONSOLE} var t1,t2,t3,t4: real; a1,a2,a3,a4: integer; k1,k2: integer; diff1, diff2: integer; i: integer; begin Assign(input,'input.txt'); reset(input); Assign(output,'output.txt'); rewrite(output); readln(t1,t2); read(t3,t4); if t1 > t2 then t2 := t2 + 24; if t3 > t4 then t3 := t3 + 24; a1:=round(t1)*60; a2:=round(t2)*60; a3:=round(t3)*60; a4:=round(t4)*60; if (t1-trunc(t1))>0.09 then a1:=a1 + round((t1-trunc(t1))*100) else a1:=a1 + round((t1-trunc(t1))*10); if (t2-trunc(t2))>0.09 then a2:=a2 + round((t1-trunc(t1))*100) else a2:=a2 + round((t2-trunc(t2))*10); if (t3-trunc(t3))>0.09 then a3:=a3 + round((t3-trunc(t3))*100) else a3:=a3 + round((t3-trunc(t3))*10); if (t4-trunc(t4))>0.09 then a4:=a4 + round((t4-trunc(t4))*100) else a4:=a4 + round((t4-trunc(t4))*10); for i:=0 to 5 do begin diff1 := a1-i*60; diff2 := a4-i*60; k1:= abs(abs(diff1-a2)); //writeln(k1 div 60,':',k1 mod 60, ' ',diff1,'-',a2,' ', abs(diff1-a2)); k2:= abs(abs(diff2-a3)); //writeln(k1 div 60,':',k1 mod 60, ' ',diff2,'-',a3,' ', abs(diff2-a3)); //writeln(diff1 div 60,':', diff1 mod 60, ' ', t2:2:2); //writeln(t3:2:2,' ',diff2 div 60,':', diff2 mod 60); if abs(k1-k2)<=10 then writeln(i); end; end. 999999999999700000 Pascal AC simple solution give 999999999.9999, but Maple returns 999999999.9998499999999999887... that must be rounded (and even truncated) to 999999999.9998 Study mathematics, 999999999.99984(9)9 this one make next digit to become from 4 to 5, and 5 is rounding up, thats why you get 9 I used "struct" in my program to sort array with two fields using qsort, and got Compilation Error. Is it possible to use "struct" type or i must uses classes? Edited by author 11.10.2008 12:52 #include <iostream> using namespace std; int main() { int n; double head,tail; cin>>n>>head>>tail; double * c =new double[n]; int i=0; while(i!=n) { cin>>c[i]; i++; } double csum=0; for(int j=0;j<n;j++) csum+=(n-j)*c[j];
double a1; a1=(head+n*tail-2*csum)/(n+1); printf("%2.2f",a1); return 0; } my mistake,head and tail should be swapped! Edited by author 09.10.2008 23:14 WA#4 program Palindome. Again Palindome; var a:array [1..20010] of char; i,j,k,n,w:integer; r:char; s:string; f:boolean; g:text; t:integer; procedure solve; label 1; var e:integer; begin f:=false; t:=0; for k:=1 to n+i do if (a[k]<>a[n+i-k+1]) then goto 1; f:=true; 1: end; {IMPORTANT PART} Begin assign(g,'input.txt'); reset(g); while not eof(g) do begin readln(g,s); n:=0; for i:=1 to length(s) do begin n:=n+1; a[n]:=s[i]; end; i:=0; repeat solve; if not(f) then begin i:=i+1; for j:=n+i downto n+1 do begin a[j]:=a[j-1]; end; a[n+1]:=a[i]; solve; end; until f; end; close(g); for j:=1 to n+i do write(a[j]); readln;readln; end. THANKS ALL RIGHT Edited by author 09.10.2008 21:19 aaaa help me!!! Edited by author 09.10.2008 21:21 See there: Sum of gnom's money must be bigger!!! bigger that sum when hi die. Not equal. Good luck! ;) Thank you very much! I got WA 1 and then, when I exchanged the symbol >= to > I got AC :D Wa Test 10. I need Testdata 10# Who can help me. i don`t understant what means "N = A + (A + 1) + … + (A + P − 1)."? i think: when A=2: 14=2+(2+1)+(2+2)+(2+3) P=? why was p=4 in the subject? please help me!!! I wrote AC solution on C++ but it failed on #5 test. Then I rewrite this code, but on Pascal then I got AC Can anybody tell me why solutions on C++ fail tests, but on Pascal it pass easily?!?!?! P.S. I'm Sorry For My Bad English Edited by author 21.11.2006 07:55 May be your C++ solution wrong? May be you need to use __int64 type in your C++ program? У меня та же проблема! Задача на Паскале проходит все тесты, но переписав на С++, получаю WA 5! Это уму не постежимо! I have the same problem! Problem writed on Pascal pass all of tests, but only I`ve rewrite it on C++, I`ve get WA 5! It is UNBELIVIBLE! Edited by author 23.04.2007 17:51 Edited by author 23.04.2007 17:51 long long N; printf("%lld", N) - works wrong there! But if I write printf("%0.lf", (double)N) - everything gets fine. Still strange to me why it is so. printf("%I64d", N) - works (I is capital "i") use int64 and it will be ok Edited by author 09.10.2008 11:18 Edited by author 09.10.2008 11:18 Please, give me Test 13! Yes, I get AC! Please, help me TEST 13 - WRONG ANSWER! Here my ALGO: program SOlve; const MAX=50000; var A,B:array[1..MAX] of integer; A_MAX,B_MAX,i,j,k,_END:integer; SUM:integer; begin readln(A_MAX); for i:=1 to A_MAX do read(A[i]); readln(B_MAX); for i:=1 to B_MAX do read(B[i]); //The main FUCK! I:=1; J:=1; _END:=A_MAX + B_MAX; for k:=1 to _END do begin if A[i] + B[j] = 10000 then begin writeln('YES'); break; end; if A[i] + B[j] > 10000 then if k <> _END then inc(j) else writeln('NO'); if A[i] + B[j] < 10000 then if k <> _END then inc(i) else writeln('NO'); end; end.
I think that some bugs can be here: _END:=A_MAX + B_MAX; for k:=1 to _END do Wait for answer.... P.s sorry for my English What is 'M'. Which of blocks belong to 'Yes','NO','Maybe' in output. Which of block belong to YES,NO,MAYBE. Are you sure that your tests are ok? Does the first test coincide with the example? I have WA1. Edited by moderator 08.10.2008 17:57 Use your own data structure to calculate the answer. My Java solution works in 0.7 sec why WA #17? who can help me.... type node=record dat,num:longint; end; var a:array[1..30000]of node; s:array[1..30000]of longint; m:longint; i,j,t,k:longint; procedure heap1(x,y:longint); var i,j:longint; k:node; begin i:=x;j:=i*2;k:=a[x]; while j<=y do begin if (a[j+1].dat>a[j].dat)and(j<y) then inc(j); if k.dat>=a[j].dat then j:=y+1 else begin a[i]:=a[j];s[a[j].num]:=i; i:=j;j:=i*2; end; end; a[i]:=k;s[k.num]:=i; end; procedure heap2(x,y:longint); var i,j:longint; k:node; begin i:=y;j:=y shr 1; k:=a[y]; while j>=1 do if a[j].dat>=k.dat then j:=0 else begin a[i]:=a[j];s[a[j].num]:=i; i:=j;j:=j shr 1; end; a[i]:=k;s[k.num]:=i; end; begin
readln(m); for i:=1 to m do begin readln(a[i].dat); s[i]:=i; a[i].num:=i; end; for i:=m shr 1 downto 1 do heap1(i,m); writeln(a[1].dat); t:=m+1; readln(k); while k<>-1 do begin s[a[m].num]:=s[t-m]; a[s[t-m]]:=a[m]; heap1(1,m-1); a[m].dat:=k; a[m].num:=t; s[t]:=m; heap2(1,m); writeln(a[1].dat); inc(t); readln(k); end; end. #include<iostream> using namespace std; int main() { int j,i,temp=0,p=0,a[10]; long long int n,k; cin>>n; if (n/10==0) { cout<<1<<n; p=1; }
for(i=9,k=n,j=0;i>1&&p==0;) { if(k%i==0) { a[j++]=i; k=k/i; temp=1; } else i--; } for(i=--j;temp==1&&i>=0&&p==0;i--) { cout<<a[i]; } if (temp==0) cout<<-1; system("PAUSE"); return(0); } |
|