Common Boardvar j,n,i:longint; t,l:extended;
begin read(n); for i:=1 to n do begin read(j); l:=j-1; l:=l*2; t:=trunc(sqrt(l)); t:=t*(t+1)/2; if (t>=j-1)and(abs(t-j+1)<=1e-6) then writeln(1) else writeln(0); end; end. program xc1; var i:integer; a0,a1,a2:longint; n,k:integer; begin read(n,k); a0:=1; a1:=k-1; for i:=2 to n do begin a2:=(k-1)*(a0+a1); a0:=a1; a1:=a2; end; writeln(a2); end. Your logic seems OK (I didn't check it, but it seems). Your problem is that the numbers might (and will) be bigger than a longint (not in the input but in the output). number 1009 you must use int64 number 1012 you must use your own count arithmatic In folder where delphi is installed open bin/ folder then copy your solution to that folder and call dcc32.exe YourProgram.pas Another way to do this in IDE is to: Create new project Remove Unit1 from that project. View project source. Remove any f**cing delphi things like uses forms, Application.Init; In the beginnig type {$APPTYPE CONSOLE}, to know wether you program is being executed. I did not checked, but I think you must comment that directive before sending program to Judge. Adding dot (.) after { is enogh: {.APPTYPE CONSOLE} Enjoy :) 1) Run Delphi. 2) Press File and chose New. There will appiare a new windows. 3) In this list chose Colsole Application. And you will start... Ural Judge System uses Delphi 2.0 compiler, so you can write your program in any version of Delphi (I use Delphi 6.0) as Console Application. To sumbit your solution just copy all the text of program. It is possible to use {$APPTYPE CONSOLE} and // comments. But you should know, that the types equal the types in Turbo Pascal 7.0. You also cann't use dynamic arrays and other features of Delphi more than 2.0 version. const nn=10; sum=1000000; type my=array[1..3000]of char; integer=longint; var a:array[1..nn]of my; n:integer; t:array[1..2,1..nn]of integer; q:array[1..nn,1..nn]of integer; kol:integer; b,bb:array[1..nn]of integer; sk:array[1..nn]of longint; koch,noch:integer; tt:array[1..nn]of set of 1..nn; kkk:longint; z:array[1..nn]of longint; procedure init; var i,l:integer; ch:char; k13:longint; begin assign(input,''); reset(input); readln(n); for i:=1 to n do begin ch:=#0; kol:=0; k13:=0; while ch<>'#' do begin read(ch); if ch='#' then break; if ch='*' then begin inc(kol); a[i][kol]:=ch; read(ch); l:=ord(ch)-48; inc(q[i,l]); inc(sk[i]); end; if (ch=#10)and(a[i][kol]=#13)then inc(k13); inc(kol); a[i][kol]:=ch; end; b[i]:=kol; z[i]:=k13; readln; end; close(input); end; procedure outNo; begin assign(output,''); rewrite(output); write('#'); close(output); halt; end; procedure createTree; var st:set of 1..nn; ch,i:integer; begin koch:=1; noch:=1; st:=[1]; t[1,koch]:=1; t[2,koch]:=0; tt[1]:=[1]; while noch<=koch do begin ch:=t[1,noch]; for i:=1 to n do if (q[ch,i]<>0)and(not (i in tt[noch]))then begin inc(koch); t[1,koch]:=i; t[2,koch]:=noch; tt[koch]:=tt[noch]+[i]; end else if (q[ch,i]<>0)and(i in tt[noch])then outNo; inc(noch); end; end; procedure calcSum; var i:integer; k1,k2,kk,ch:integer; begin for i:=koch downto 2 do begin k1:=t[2,i]; k2:=t[1,i]; kk:=q[k1,k2]; b[k2]:=b[k2]-2*sk[k2]-z[k2]; b[k1]:=b[k1]+kk*b[k2]; end; b[1]:=b[1]-2*sk[1]-z[k1]; if b[1]>sum then outNo; end; procedure solve; begin bb:=b; createTree; calcSum; end; procedure writeAns(k,pp:integer); var i:integer; kk:integer; begin i:=pp; while i<=bb[k] do begin if (a[k][i]='*')then begin kk:=ord(a[k][i+1])-48; writeAns(kk,1); inc(i,2); end else begin if (i<=bb[k]) then begin write(a[k][i]); inc(kkk); end; inc(i); end; end; end; procedure outt; begin assign(output,''); rewrite(output); writeAns(1,1); close(output); end; begin init; solve; outt; end. > const nn=10; > sum=1000000; > > type my=array[1..3000]of char; > integer=longint; > > var a:array[1..nn]of my; > n:integer; > t:array[1..2,1..nn]of integer; > q:array[1..nn,1..nn]of integer; > kol:integer; > b,bb:array[1..nn]of integer; > sk:array[1..nn]of longint; > koch,noch:integer; > tt:array[1..nn]of set of 1..nn; > kkk:longint; > z:array[1..nn]of longint; > > procedure init; > var i,l:integer; > ch:char; > k13:longint; > begin > assign(input,''); > reset(input); > readln(n); > for i:=1 to n do > begin > ch:=#0; > kol:=0; > k13:=0; > while ch<>'#' do > begin > read(ch); > if ch='#' then break; > if ch='*' then > begin > inc(kol); > a[i][kol]:=ch; > read(ch); > l:=ord(ch)-48; > inc(q[i,l]); > inc(sk[i]); > end; > if (ch=#10)and(a[i][kol]=#13)then inc(k13); > inc(kol); > a[i][kol]:=ch; > end; > b[i]:=kol; > z[i]:=k13; > readln; > end; > close(input); > end; > > procedure outNo; > begin > assign(output,''); > rewrite(output); > write('#'); > close(output); > halt; > end; > > procedure createTree; > var st:set of 1..nn; > ch,i:integer; > begin > koch:=1; > noch:=1; > st:=[1]; > t[1,koch]:=1; > t[2,koch]:=0; > tt[1]:=[1]; > while noch<=koch do > begin > ch:=t[1,noch]; > for i:=1 to n do > if (q[ch,i]<>0)and(not (i in tt[noch]))then > begin > inc(koch); > t[1,koch]:=i; > t[2,koch]:=noch; > tt[koch]:=tt[noch]+[i]; > end else > if (q[ch,i]<>0)and(i in tt[noch])then outNo; > inc(noch); > end; > end; > > procedure calcSum; > var i:integer; > k1,k2,kk,ch:integer; > begin > for i:=koch downto 2 do > begin > k1:=t[2,i]; > k2:=t[1,i]; > kk:=q[k1,k2]; > b[k2]:=b[k2]-2*sk[k2]-z[k2]; > b[k1]:=b[k1]+kk*b[k2]; > end; > b[1]:=b[1]-2*sk[1]-z[k1]; > if b[1]>sum then outNo; > end; > > procedure solve; > begin > bb:=b; > createTree; > calcSum; > end; > > procedure writeAns(k,pp:integer); > var i:integer; > kk:integer; > begin > i:=pp; > while i<=bb[k] do > begin > if (a[k][i]='*')then > begin > kk:=ord(a[k][i+1])-48; > writeAns(kk,1); > inc(i,2); > end else > begin > if (i<=bb[k]) then > begin & Read task with attention. Only Latin letters must be transformed. Others symbols simply are printed on screen. Simple input and output files are incorrect. > Read task with attention. Only Latin letters must be transformed. > Others symbols simply are printed on screen. Simple input and output > files are incorrect. It doesn't work, Buddy Can one file be read twice? e.g assign(input,''); reset(input); read(...); ... reset(input); read(...); Thanks? Program Memory_Management; Type Lion=Record Num,Time:word; End; Var i,j,k,k1,m,n,r,t,Pos:longint; c:char; Ld,Rd,Left,Right:array[0..30001] of Word; Action:array[0..80001] of Lion; Time:array[0..30001] of Word; Procedure MakeTree(x,Min:word); Var k:Word; Begin if x=Min then begin Left[x]:=0; Right[x]:=0; Ld[x]:=0; Rd[x]:=0; exit; end; k:=(x-Min) shr 1 +Min; Left[x]:=k; MakeTree(k,Min); Ld[x]:=Ld[k]+Rd[k]+1; if x-1>k then begin Right[x]:=x-1; MakeTree(x-1,k+1); Rd[x]:=Ld[x-1]+Rd[x-1]+1; end else begin Right[x]:=0; Rd[x]:=0; end; End; Procedure Add(x:Word); Begin inc(t); Action[t].Num:=x; Action[t].Time:=k+600; Time[x]:=k+600; writeln(x); end; Procedure Find_Del(x:Word); Begin if (Ld[x]=0)and(Rd[x]=0) then Add(x) else if Ld[x]>0 then begin Find_Del(Left[x]); dec(Ld[x]); end else begin Find_Del(Right[x]); dec(Rd[x]); end End; Procedure Find_Inc(x:longint); Begin if x=Pos then exit; if Left[x]>=Pos then begin Find_Inc(Left[x]); inc(Ld[x]); end else begin Find_Inc(Right[x]); inc(Rd[x]); end; End; Begin Fillchar(Time,sizeof(Time),0); MakeTree(30001,1); r:=1; t:=0; while not(eof) do begin read(k); repeat read(c); until c<>' '; while (r<=t)and(Action[r].time<=k) do begin if Action[r].time=time[Action[r].Num] then begin Pos:=Action[r].Num; Find_Inc(30001); Time[Action[r].Num]:=0; end; inc(r); end; if c='.' then begin read(k1); if k<Time[k1] then begin writeln('+'); inc(t); Action[t].Num:=k1; Action[t].time:=k+600; Time[k1]:=k+600; end else writeln('-'); end else Find_Del(30001); readln; end; End. Sorry ! How careless I am ! I got ac now var n, i, j : integer; begin readln(n); for i:=n downto 1 do begin writeln(n-i); for j:=1 to i do writeln('X'); for j:=1 to i do writeln('*'); end; for i:=1 to n do writeln('+'); end. I have register an ID before,but I forget the judge_ID,What should I do? > I have register an ID before,but I forget the judge_ID,What should I > do? please give me any trick for multiplying bignum ! i got tl and why solution for a(n) is... a(n)=pow(a(n-1),2)-a(n-1)+1; a(n)= a(n-1)^2-a(n-1) + 1 the way to do the problem is very easy, you see, the first fraction is obviusly the least which is 1/2 then you may want a fraction which is less than this last one but added with this leads to minimum left, so you may want a fraction the more likely to 1/2, this is 1/3 (2+1), then with this to add a third fraction, this will be 1/2 + 1/3 + ?, could be 1/6, but this leads to get a sum of 1, so the next will be 1/7 (2*3 + 1), the next will be 1/43 (2*3*7 + 1), the formula you put is a pretty factorization of this. There's a method to do multiplications on O(n^1.54), but i don't know how to do it exactly, you may want to see it in a book. Good Luck :) Miguel Angel. miguelangelhdz@hotmail.com An easyier way to get AC is to represent the bignums in base 1000. There is a lot of time saving an the modifications needed to be done when writing the output are easy (just add some 0s if a[j]<100 and a [j]<10). As for the O(N^1.58) algo, you were supposed to split the numbers into two halfs: A=C*10^n/2+D and B=E*10^n/2+F. G=(C+D)*(E+F)=C*E+D*F+C*F+D*E Then A*B=C*E*10^n+(G-C*E-D*F)*10^n/2+D*F We only hav to do 3 multiplications instead of 4 (G,C*E,D*F). In order to do these multiplication we use the same algorithm, until C,E,D,F on have one digit. var p,a,n:longint; begin readln(n); p:=n; while (2*n mod p<>0) or ((2*n-(p+1)*p)<0) do if p>0 then dec(p) else halt; a:=(2*n-(p-1)*p) div (2*p); writeln(a,' ',p); end. Here is my source: #include <stdio.h> int k; int capital(char c); // if capital then return 1 if notcapital return 0 // if not letter return 2; int mystrlen(char s[]); int main(void) { int i, j; int mistake = 0; char str[10000]; gets(str); for(j = 0; j < mystrlen(str)-1; j++) if(str[j] > 64 && str[j] < 123) break; if(capital(str[j]) == 0) mistake++; i = j; for(; i < mystrlen(str) - 1; i++) { if(str[i] == '.' || str[i] == '!' || str[i] == '?') { for(j = i; j < mystrlen(str)-1; j++) if(str[j] > 64 && str [j] < 123) break; if(capital(str[j]) == 0) mistake++; i = j; } } for(i = 0; i < mystrlen(str) - 1; i++) { if(capital(str[i-1]) == 2 && (str[i] > 64) && (str[i] < 123)) { i++; for(j = i; capital(str[j]) != 2; j++) { if(capital(str[j]) == 1) mistake++; } i = j; } } printf("%d", mistake); return 0; } int capital(char c) { if(c >= 65 && c <= 90) return 1; else if(c >= 97 && c <= 122) return 0; else return 2; } int mystrlen(char s[]) { for(k = 0; s[k]; k++); return k; } I've had some trouble solving this and I'm sure there are some tests where ai>bi. How do I know? Well, I got a lot of WAs, so at some point I inserted this into my code, where I read the data: if ai>bi then while 1=1 do writeln('Error!'); Guess what? I got Output Limit Exceeded instead of WA. So if you want to get AC, you also have to ignore the lines where ai>bi. on gnu gcc 3.1 I can use long long type (wich is a 64-bit int). Here trying to submit a solution that use this type I get compilation error. what is the compiler used here? How I can use 64-bit integer with C? Program Task1209; { Binary Search } Var L,R,Num,N,I : Word; K,T : LongInt; Function F(Const A : LongInt) : LongInt; Begin F := A * (A + 1) Shr 1; End; BEGIN ReadLn(N); For I := 1 To N Do begin ReadLn(K); If K = 1 Then Write('1 ') Else begin L := 1; R := 40000; While R - L <> 1 Do begin Num := (R + L) Shr 1; T := F( Num ); If K > T Then L := Num Else R := Num; end; Num := (R + L) Shr 1; T := K - F( Num ); If T = 1 Then Write('1 ') Else Write('0 '); end; end; END. What is "CRASH(ACCESS_VIOLATION)"? You use memory that you cannot to use(for example, it can be range check error or using pointers without New/GetMem). #include <iostream> using namespace std; void cout_a(int m,int n){ if(m==n) cout<<"sin("<<n<<")"; else{ cout<<"sin("<<m<<"+"; cout_a(m+1,n); cout<<")"; } } void cout_s(int m,int n){ if(m==1){ cout_a(1,1); cout<<"+"<<n; } else{ cout<<"("; cout_s(m-1,n); cout<<")"; cout_a(1,m); cout<<"+"<<n+1-m; } } int main(void){ int n; cin>>n; cout_s(n,n); cout<<endl; return 0; } I know.I am using GB2312.So I see -s as –s. The following is the AC code. #include <iostream> using namespace std; void cout_a(int m,int n){ if(m==n) cout<<"sin("<<n<<")"; else{ cout<<"sin("<<m; if(m%2==1) cout<<"-"; else cout<<"+"; cout_a(m+1,n); cout<<")"; } } void cout_s(int m,int n){ if(m==1){ cout_a(1,1); cout<<"+"<<n; } else{ cout<<"("; cout_s(m-1,n); cout<<")"; cout_a(1,m); cout<<"+"<<n+1-m; } } int main(void){ int n; cin>>n; cout_s(n,n); cout<<endl; return 0; } (2/3,2/3) (3,2) (2,3) is also ok Is anyone solution is ok? No.There is only one output for every input. Program Eagle; type arr=array[1..10000]of integer; Var a:arr; n,m,k,l,o,p:Longint; Procedure check(a:arr); Var i:longint; Begin i:=255; while a[i]=0 do dec(i); l:=0; If a[i]>=4 then o:=i+1 else o:=i; End; Procedure divided(n:longint); Begin k:=0; If n mod 3=0 then m:=n div 3; If n mod 3=1 then Begin m:=n div 3-1;k:=2;end; If n mod 3=2 then begin m:=n div 3;k:=1;end; end; Procedure timesed(m,k:longint); Var i,j,i1,j1,k1,l:Longint; Begin a[1]:=1;k1:=0; i:=0;If m>=1 then Repeat inc(i);j:=0;l:=1; i1:=255;while a[i1]=0 do dec(i1); Repeat inc(j); a[j]:=3*a[j]+k1; k1:=a[j] div 10; a[j]:=a[j] mod 10; inc(l); Until j=i1+1; Until i=m; i:=0; If k>=1 then Repeat inc(i);j:=0;l:=1; i1:=255;while a[i1]=0 do dec(i1); Repeat inc(j); a[j]:=2*a[j]+k1; k1:=a[j] div 10; a[j]:=a[j] mod 10; inc(l); Until j=i1+1; Until i=k end; Begin Readln(n); Fillchar(a,sizeof(a),0); If n<=3 then Begin If n=1 then write(1); if n=2 then write(2); If n=3 then write(3); halt; end; divided(n); timesed(m,k); o:=255; While a[o]=0 do dec(o); For p:=o downto 1 do write(a[p]); writeln; readln End. |
|