Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Its very very easy!!! | RASTA | 1354. Palindrome. Again Palindrome | 19 Mar 2009 13:33 | 1 | my idea for solution k := 2; n := length(s); s1 := s[1]; while true do begin i := 0; while (n - i >= k + i) and (s[k + i] = s[n - i]) do inc(i); if n - i <= k + i then begin write(s + s1); halt; end; s1 := s[k] + s1; inc(k); end; | | Misspelled problem name | Fyodor Menshikov | 1375. Bill Clevers | 19 Mar 2009 11:59 | 2 | In Russian, the name of the problem is noncomformizm, it should be nonco_n_formizm. | | Wrong answer | Mansur | 1698. Square Country 5 | 19 Mar 2009 10:42 | 2 | В чем ошибка? #include<stdio.h> #include<math.h> void main() { int n,k=0,i=1,j,m; scanf("%d",&n); for(j=1;j<=n;j++) { m=pow(10,j); while (i<m) { if (i*i%m==i) {k++; printf("\n%d %d",i,i*i);} if (i%10==1) i=i+4; else if (i%10==5) i++; else if (i%10==6) i=i+5; } } printf("%d",k); } pow(10, 2000.)? //1 ≤ n ≤ 2000 | | 2 ADMINS: Weak tests!!! | Vedernikoff Sergey (HSE: АОП) | 1694. Killer Words | 19 Mar 2009 08:16 | 6 | I'm pretty sure that testset for this problem doesn't contain maxitests with k=2 and n=22. Otherwise how could program that works about 20sec. on my computer get AC on timus??? Then what supercomputers does timus use??? =) I have Pentium Duo Centrino 3.2 Or you want to say that the whole difference is due to compilers? (I use MSVS C++ 8.0) you can easily test how fast it works on timus online judge.... dont read data from input , run your program when m = 18, k = 2 , and n = 22. I'm sure your solution is fast enough , for example, when I'm using STL classes, program works on my PC 10 times slower than on online judge... use Release option in your compiler Site news contain information about testing computer: Core 2 Quad Q6600 (frequency 2400 MHz, L2 cache 8 MB, bus frequency 1066 MHz). | | My algo may seem interesting to you | melkiy | 1195. Ouths and Crosses | 19 Mar 2009 07:36 | 1 | No recursion or brute force would needed, if you could guess some regularity. Of course this requires some thoughts from you ;) My main() contains only these lines but input: if(canWinNow('X') > 0 || existsMagicCell('X')) CROSSESWIN else if(canWinNow('O') > 1) OUTHSWIN else DRAW What canWinNow() does you may guess yourself, and existsMagicCell() contains about 10 lines and is not recursive. Who wants to find out my algo write a-zakh [at] yandex.ru | | TLE test 28??? | FreezingCool | 1494. Monobilliards | 18 Mar 2009 19:50 | 2 | Hey, Can anyone tell me what is test 28?? I have time limit exceeded? This is my code: program Monobilliards_1494; var tmp, b, a, i, n: LongInt; x: array [1..100000] of LongInt; cheater: boolean; begin cheater := false; readln(n); for i := 1 to n do readln(x[i]); i := 1; tmp := x[1] - 1; while (i <= n) and not cheater do begin if tmp < x[i] then begin b := x[i] - i; tmp := x[i]; a := i + 1; while (a <= n) and (b > 0) do begin if tmp > x[a] then begin b := b - 1; tmp := x[a]; end; a := a + 1; end; end; tmp := x[i]; if b > 0 then cheater := true; i := i + 1; end; if cheater then writeln('Cheater') else writeln('Not a proof'); end. | | I have WA#10. Can you help me? | Max Pilgrim | 1191. Catch the thief! | 18 Mar 2009 19:38 | 1 | I have WA#10. Can you help me? here is my code: program _1191; {$APPTYPE CONSOLE} uses SysUtils; var k:array[1..100]of longint; l,n,i,q,z:longint; begin reset(input,'input.txt'); rewrite(output,'ouput.txt'); read(l,n); q:=1; z:=0; for i:=1 to n do begin read(k[i]); z:=z+k[i]; if l<z then begin write('YES'); halt(0); end else while l>z+q*k[i] do inc(q); l:=z+q*k[i]; q:=1; end; write('NO'); end. Edited by author 18.03.2009 19:38 | | Can any1 help what is wrong here??? | Swifty | 1243. Divorce of the Seven Dwarfs | 18 Mar 2009 18:01 | 1 | var a:array [1..50] of byte; i,n,q:byte; ch:char; k:longint; begin i:=0; while not(eoln) do begin inc(i); read(ch); a[i]:=ord(ch)-48; end; n:=i; q:=0; for i:=n downto 1 do begin inc(q); if q mod 7=1 then k:=k+(a[i]); if q mod 7=2 then k:=k+(a[i]*3); if q mod 7=3 then k:=k+(a[i]*2); if q mod 7=4 then k:=k+(a[i]*6); if q mod 7=5 then k:=k+(a[i]*4); if q mod 7=6 then k:=k+(a[i]*5); end; writeln(k mod 7); readln; end. WA #2 test... | | Please give me test!!! | Makcum | 1243. Divorce of the Seven Dwarfs | 18 Mar 2009 17:55 | 2 | I have WA on second test! Please help me! PS Sorry fr bag English same problem. Can anyone show #2 test??? | | How to improve my Algo. I got TL on test 4 | Todor Tsonkov | 1462. Uncle Scrooge's Gold | 18 Mar 2009 15:10 | 22 | I try to find fib(2*n-2)/fib(n-2) but I get TL on test 4, my algo is linear so I couldn't pass the TL, I wonder is the direct algo for finding fib(n-2) and fib(2*n-2) better, because I couldn't implement it :) i have tl too, but i find that fib(2*n-2)/fib(n-2)=fib(n+1)+fib(n-1) ^) but i have tl ( fib(n) could be evaluated in O(log n) multiplication operations. Well, my idea was to evaluate fib(n-2) and fib(2*n-2) using the direct formula for fib(n)- as function of n, but I couldn't implement it , while the bruteforce solution was TL, anyway I'm gonna think a bit more about it, btw congrats for the victory, guys, you did a great job, also a great competiton for ACRush as always :) Hint: direct formula is hard to implement, but we can rewrite it using linear algebra like this: .....................................(0, 1)^(n-1) (fib(n), fib(n+1))=(1, 1)*(....) .....................................(1, 1) , so we can use integer arithmetics! Edited by author 12.08.2006 21:05 Edited by author 12.08.2006 21:05 Edited by author 12.08.2006 21:05 Edited by author 12.08.2006 21:06 Edited by author 12.08.2006 21:06 Edited by author 12.08.2006 21:06 Who can you write me om email the algorithm or in what book i can find it? Thanks. adas@simnet.kiev.ua What is the answer fo this test? n = 7000 81937319032993876558582070063011262115783024656965723338526424275071630557443673768160691777974344039339079218543821663526642065353277478431909789983160736348837929626796434540999450923786205450782143686270382692873692233405139629109704561270312322297501776980155782647708033073460077811847296059544586515736242655594916292010288630241998587835886957464588315061688674744586049802510938100726026534538639883653835446753146728656928193874140316597540202353213455487305219113003826047850156459479457447951648423579548704045234844929446845423587933723079796158760129023524040519672308404718221125336963212128205511547407802595672777585867901520427711491099757592076124797583476061864630025076181920889182653070760272884159824308542397653852400985696907858408387639956157978706489167805462854368911415071677899319871467455602850964575780531369593561207038707991166116257391616617990142018311285809472372949541001826651548109149596409807197380997932230498982610632747317000197354547509949735065278160290108373521163485352357077038417341404680343430978229222267611931184569548788576280109768575772879672619415599295926884517066063939649588253695834282602632479823971486742422068816044196848224503022646081677385555572595399717609483383203051148447238015528377198350218937442030369055848713320280710524550172256486540262008219704955151944469303730096667265538925353091481286313382299155890271045282453432557272252772046637042581378078908572780035752442042046549675078127 I know how to calc Fn in O(log n). But also i must use long arithmetic and TL in result. Give some hints please Just use java.math.BigInteger in Java.=) Yup, I used BigInteger but O(n) gave me TL, so does there exist a solution which doesn't use advanced maths techniques such as the described above, because I tried to use BigDecimal but it loses precision when trying to calculate directly Fib(n) It`s improbable task! While I use quick power raising of matrix, I still got tl Then I tried to calculate it lineary and got AC, c++ Hi Boris :) Here my sol: There is sequence a(i)=a(i-1)+a(i-2), a(1)=1,a(2)=3. Ans for this problem is a(n). I tried to calculate it O(n) and it taked ~ 17 sec in n=40000. Then I tried to calculate it o(logN) and it,of course, slower then O(n). Is there any special quick algo for long numbers?(sum or product) Edited by author 31.08.2006 17:50 Re: Test data Kaliningrad SU -J_A_MES-HeadLiner 31 Aug 2006 20:45 Of course there are fast algorithms for long multiplication. Try to find FFT or FHT. The actual answer is fib(2*n-1)/fib(n-1). Just check the sample answer.... Yup, but if you use some math knowledge you will find that the result is fib(n-1)+fib(n+1), during the competition as far as I got was the result you mentioned, but I think implementing it is improbable task, anyway can someone send accepted C++ solution to me at ttsonkov [at] gmail.com, I'd be very grateful, cos I implemented the algo with the matrix but I still get TL. Anyway, Java rulez!!! O(logn) got accepted in about 0.7s. ,yet it would be interesting to see some C++ solutions What do you mean result is fib(n-1)+fib(n+1)? For sample (n=3) fib(2)+fib(4)=2+5=7, but real answer is 4. Check that yourself @spirit: It depends on how you get the Fibbonacci sequence if fib(1)=1, fib(2)=1, fib(3)=2 and etc. you get the desired result :) Well, then my formula is fib(n-2)+fib(n) I use linear algo O(N) + long addition (10^18), but I got TL#4 :( Please help me. | | How to more optimize~Code here...Thank you!!! | Search | 1462. Uncle Scrooge's Gold | 18 Mar 2009 14:59 | 2 | #include <cstdio> #include <string> #include <memory> using namespace std; class BigInteger{ private: enum{MAXLENGTH=14900}; int m[MAXLENGTH]; int len; public: BigInteger(int n) { memset(m,0,sizeof(m)); len=0; if (n == 0) len++; while (n > 0) { m[len++] = n % 10; n = n / 10; } } BigInteger(void) { memset(m,0,sizeof(m)); len=1; } void print(void) { int temp = len-1; while(temp>=0) printf("%d",m[temp--]); } BigInteger operator+ (const BigInteger &a) { int i,carry = 0; BigInteger Temp(*this); if (a.len > Temp.len) Temp.len = a.len; for(i=0;i<Temp.len;i++) { Temp.m[i] += (a.m[i] + carry); carry = Temp.m[i] / 10; Temp.m[i] %= 10; } if (carry > 0) {Temp.m[i] = carry; Temp.len++;} return Temp; }
int operator> (const BigInteger &a) { int i; if (len > a.len) return 1; if (len < a.len) return 0; for(i=len-1;(m[i] == a.m[i]) && (i>0);i--); if (m[i] > a.m[i]) return 1; return 0; } int operator== (const BigInteger &a) { int i; if (len != a.len) return 0; for(i = len-1;i>=0;i--) if (m[i] != a.m[i]) return 0; return 1; }
}; int main() { int n; scanf("%d",&n); BigInteger r1;int i; BigInteger previous = -1; BigInteger result = 1; for (i = 0; i<n; i++) { BigInteger const sum = result + previous; previous = result; result = sum; if(i==n-3){ r1=result; } } (r1+result).print(); return 0; } Edited by author 25.09.2008 01:10 Use long ariphmetics on base 10^9 or 10^18, but not 10^1 :) | | Can someone give me a hint? | Meriones | 1690. Army of Mages | 18 Mar 2009 11:12 | 1 | | | Strange(WA1) | Alexander Sokolov [MAI-7] | 1545. Hieroglyphs | 18 Mar 2009 10:42 | 4 | Why this gets WA1? //--------------------------------------------------------------------------- #include <iostream.h> #include <memory.h> int main() { bool mas[30][30]; for (int i=0; i<30; ++i) for (int j=0; j<30; ++j) { mas[i][j]=false; } int n; char ch,ch1,ch2; cin>>n; for (int i=0; i<n; ++i) { cin>>ch1>>ch2; mas[ch1-'a'][ch2-'a']=true; } cin>>ch; for (int i=0; i<30; ++i) { if (mas[ch-'a'][i]) { cout<<ch<<(char)(i+'a')<<endl; } } cin>>ch; return 0; } //--------------------------------------------------------------------------- //what about RC/LF ? //for example //there is a text text file which contents some symbols ab ac ba //but on your hard disk drive it is look as ( in hexadimal ) "61620D0A61630D0A62661" //0D0A it is an linefeed in windows //and when you are read as cin >> ch1; //you read all characters from input file include these symbols; //instead of cin >> x >> y ( when x and y have type "char") //you must to use char s[10]; cin.getline(s,10); x = s[0]; y = s[1]; //or char s[10]; scanf("%s", s); x = s[0]; y = s[1]; or scanf("%c%c\n",&x,&y); It does not work((( Can u mail me your solution to diablo_@list.ru? | | where is my mistake? | ooo | 1545. Hieroglyphs | 18 Mar 2009 10:41 | 2 | #include <iostream.h> int main() { const int n=30; int a[n][n], i, N,j,k; cin>>N; for(i=0; i<N; i++) for(j=0; j<N; j++) cin>>a[i][j]; cin>>k; for(j=0; j<n; j++) cout<<a[k][j]; return 0; } | | NO.5!! | ☞ⓩⓢⓨⓩ™ⓣⓔⓢⓣ☜ | 1150. Page Numbers | 18 Mar 2009 10:34 | 1 | NO.5!! ☞ⓩⓢⓨⓩ™ⓣⓔⓢⓣ☜ 18 Mar 2009 10:34 | | what is wrong??? | Rockman | 1249. Ancient Necropolis | 18 Mar 2009 09:11 | 1 | #include<iostream> using namespace std; int main () { int a[3000],b[3000],c[3000]; long long int i,j,k,n,m; cin>>n>>m; for (i=0;i<n;i++){ cin>>a[i]; for(j=0;j<m;j++){ cin>>a[j]; } { c[j]= a[j] + b[j]; } for (j=0;j<m-1;j++){ if ((c[j] = 1) && (c[j+1] = 2) || (c[j] = 2) && (c[j+1] >= 1)) { cout<<"NO";
return 0; } else { cout<<"YES";} } } return 0; } | | What's the test 8 | yuyan | 1588. Jamaica | 18 Mar 2009 06:07 | 1 | Why I WA on #8?I can't find what's wrong with my program. Here is my code: program jamaica; const maxn=310; var k,b,l:array [0..maxn*maxn] of extended; x,y:array [0..maxn] of int64; i,j,m,n,min,max:longint; ans,d:double; procedure init; begin readln(n); for i:=1 to n do readln(x[i],y[i]); end; procedure qsort(head,tail:longint); var i,j,t,k:longint; begin if head>=tail then exit; i:=head;j:=tail; t:=x[(i+j) shr 1]; repeat while x[j]>t do dec(j); while x[i]<t do inc(i); if i<=j then begin k:=x[i];x[i]:=x[j];x[j]:=k; k:=y[i];y[i]:=y[j];y[j]:=k; inc(i);dec(j); end; until i>=j; qsort(head,j); qsort(i,tail); end; procedure sort(head,tail:longint); var i,j:longint; x,y,t:double; begin if head>=tail then exit; i:=head;j:=tail; x:=k[(i+j) shr 1];y:=b[(i+j) shr 1]; repeat while (k[j]-x>1e-8) or (abs(k[j]-x)<1e-8) and (b[j]-y>1e-8) do dec(j); while (k[i]-x<-1e-8) or (abs(k[i]-x)<1e-8) and (b[i]-y<-1e-8) do inc(i); if i<=j then begin t:=k[i];k[i]:=k[j];k[j]:=t; t:=b[i];b[i]:=b[j];b[j]:=t; t:=l[i];l[i]:=l[j];l[j]:=t; inc(i);dec(j); end; until i>=j; sort(head,j); sort(i,tail); end; procedure solve; begin qsort(1,n); ans:=0; min:=y[1];max:=y[1]; for i:=2 to n do if x[i]<>x[i-1] then begin ans:=ans+max-min; max:=y[i];min:=y[i]; end else begin if y[i]>max then max:=y[i]; if y[i]<min then min:=y[i]; end; ans:=ans+max-min; m:=0; for i:=1 to n-1 do for j:=i+1 to n do if x[i]<>x[j] then begin inc(m);k[m]:=(y[j]-y[i])/(x[j]-x[i]);b[m]:=y[i]-k[m]*x[i]; l[m]:=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j])); end; sort(1,m); d:=l[1]; for i:=2 to m do if (k[i]<>k[i-1]) or (b[i]<>b[i-1]) then begin ans:=ans+d; d:=l[i]; end else begin if l[i]>d then d:=l[i]; end; ans:=ans+d; end; begin init; solve; writeln(round(ans)); end. | | Weak tests | Fyodor Menshikov | 1022. Genealogical Tree | 18 Mar 2009 00:20 | 1 | I know AC solution that answers 3 2 1 for test 3 0 3 0 1 0 The only right answer for this test is 2 3 1 | | C# Crash test #8 | derxyz | 1193. Queue at the Exam | 17 Mar 2009 15:03 | 1 | Crash, because in Input numbers t1, t2, t3 separeted more then one space. So, I replaced string[] ss = Console.ReadLine().Split(' '); to string[] ss = Console.ReadLine().Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries); and got AC. | | Why doesn't it work? (Pascal) | Igor | 1001. Reverse Root | 17 Mar 2009 14:34 | 3 | type TStack=class(TObject) public Data:Extended; Next:TStack; function Add(AData:Extended):TStack; function Delete:TStack; end; function TStack.Add(AData:Extended):TStack; begin Result:=TStack.Create; Result.Data:=AData; Result.Next:=Self end; function TStack.Delete:TStack; begin Result:=Next; Free; end; var Stack:TStack; AData:Extended; begin Stack:=nil; while not eof do begin Read(AData); Stack:=Stack.Add(AData) end; while Stack<>nil do begin Writeln(Sqrt(Stack.Data)); Stack:=Stack.Delete end; end. Edited by author 17.03.2009 14:43 |
|
|