Common BoardI got wrong answer for test #11 for the follwing code ...... can anybody tell the error in this code..... #include <stdio.h> void isPalendrome(char check[]); int flag1 = 0; main() { int i,j,k=1,l,len,upper_limit,lower_limit,n; char string[1001],check[1001]; scanf("%s", string); n = strlen(string); len = n-1; isPalendrome(string); while(flag1==0&&len>0) { k++; lower_limit=0; for(i=0;i<k;i++,lower_limit++) { for(j=lower_limit;j<len;j++) check[j] = string[j]; isPalendrome(check); if(flag1==1) break; } upper_limit = n-1; if(flag1==0) { for(i=0;i<k;i++,upper_limit--) { for(j=upper_limit,l=len-1;l>=0;j--,l--) check[l] = string[j]; isPalendrome(check); if(flag1==1) break; } } len--; check[len] ='\0'; }
}
void isPalendrome(char check[]) { int len,i,j,flag2=0; len = strlen(check); j = len-1; len = len/2; for(i=0;i<len;i++,j--) { if(check[i]!=check[j]) { flag2 = 1; break; } } if(flag2==0) { flag1 = 1; printf("%s",check); scanf("%s",check); return; } else return; } Anupam Ghosh,Bengal Engg and Science University,Shibpur,India i got AC [1] // Problem 1079. Maximum 26 Feb 2008 14:43 just use recursion along with array. And now try to solve 1396. Maximum. Version 2 Edited by author 27.02.2008 00:00 Edited by author 27.02.2008 00:00 I have two solutions. The first easily gets AC, and the second passes stress test with the first but fails on the 12-th test. If you know the 12-th test or some special cases for this problem, my email is sk1@hotbox.ru. ------------------ Sergey Kopeliovich daite pozhaluista formulu vichislenia ploshadi segmenta give me please segment's formule (Pi*r^2*Angle) / 360 umeesh zadashi sostavlat na Delphi7 ili Pascal7 Go!Go! I want /// I'm very small speak english! please help me! var a : array [1.. 10000000000000000] of int64; n,i : longint; begin {$IFNDEF ONLINE_JUDGE} assign (input,'Input.txt'); assign (output,'Output.txt'); reset (input); rewrite (output); {$ENDIF} I:=0; while not seekeof do begin inc(i); read(a[i]); for n:=i downto 1 do writeln(sqrt(a[n])); end; {$IFNDEF ONLINE_JUDGE} close(input); close(output); {$ENDIF} readln; end. First: You needn't so big array... Second: Try first to read whole input, and than output it in reverse oreder. Third one: you should use extended type, not int64 one please show me the form of submiting problems. e.g. the address i send to the topic of my e-mail then content in my e-mail please help me . #include<iostream> using namespace std; int CountOf(int n){ int count=0,div=2; while(n!=1){ while(n%div) div++; count++; n/=div; } return count+1; } void main() { short T; cin>>T; int i,*A,*B; A=new int[T]; B=new int[T]; for(i=0;i<T;i++){ cin>>A[i]>>B[i]; } for(i=0;i<T;i++) { if(A[i]==0) cout<<0<<endl; else cout<<((A[i]>B[i] || B[i]%A[i]) ? 0:CountOf(B[i]/A[i]))<<endl; } } Mishex WA 1404 [1] 22 Feb 2008 03:10 Hi, please, tell me Why do my task solve number 1404 take WA#1: #include <stdio.h> char Change(char ch); int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif char ch; scanf("%c", &ch); while (!feof(stdin)) { ch=ch-'a'; printf("%c", Change(ch)+'a'); scanf("%c", &ch); } return 0; } char Change(char ch) { static int s=5; int ch_res=ch-s; while (ch_res<0) { ch_res+=26; } s+=ch_res; return ch_res; } This program output: "secret" on first test from task's condition, but take WA#1 I have Ac(0.015) by diagonal sequantal placing nambers 1..N*N from max and min alternating 25 2 22 6 2 17 1 23 5 18 10 24 4 19 9 14 3 20 8 15 12 21 7 16 11 13 but clear mathamatic proof i don't now and this is most interesting. I will try find out such proof and if people will have interest will send this proof to forum. Without proof algotithm hasn't hard foundation. So, what is your algo, svr? After building your matrix, what are you doing? Thanks. Edited by author 17.10.2006 13:53 If we have optimal matrix to take answer is very simple problem. We use double loop, calculate sums A[i,j]+A[i-1,j] and A[i,j-1]+A[i,j] and renew record value searching max. First number is always : (n - 1). Second if n even => 3 * ((n - 2) / 2) + 1 If n odd => 3 * ((n - 1) / 2) Yes, I have also maden by this way. My program is in 7 lines(without var,begin,end - 3). But I don'y understand why it works in 0.015, except 0.001. I used only 1 read and if. strange isn't it? what is answer if n=8 when only one match with win&lose ,and other is draw answer should be 6 9 (6(1)+3)? Edited by author 24.02.2008 13:21 Edited by author 24.02.2008 13:21 Var n:LongInt; Begin ReadLn(n); If n=0 then WriteLn(1) else WriteLn((abs(n+1)*(n-1)+n+1) div 2); End. qardas bu dusturu azi 10 defe hemin forumda veribler ACM.Tolstobrov_Anatoliy[Ivanovo SPU] ? [1] // Problem 1068. Sum 21 Jan 2006 16:38 But Who Cares You Simple Program? Edited by author 16.02.2006 00:11 Hey... you even know the quantity of correct formulas on this forum... smart boy... It means that you needed them =) P.S. Plz speak in English - This is an international forum! Afgan, Necesan? Ne var ne yox? Gorurem sen de teze bashdamisan... Sual olsa yaz! no i did not need them. I visited forum after i got AC. ele bele. meze ucun.... Edited by author 24.01.2006 12:51 Qardas bu formulun duz deyirsen 100 cur novunu yaziblar.Men istedim daha yaxsisi olsun.Umumi olsun.Ona gore bunu yazdim.Formul + ve - ucun eynidir(duz isleyir),yalniz sifirda sehvdir.Onuda if ile gostermisem. This formule calculate - and + correct.Only n=0 then calculate false. Please do not give the right source code here. It gives chance to some people to unfairly get AC. Even if it's a very simple task. aaaah. what the hell. he's right. who cares? Edited by author 13.03.2008 12:16 bu suali 30 deq umumi bir dustur oturub cixardim ve istedimki,buraya yazim.bu dustur yalniz 0-da sehv gosterir.Evvelce bu formulun burada olduqunu bilmirdim,sonradan gordun.Sene bu dusturun cixarilisini Bakiya derse gelende gostererem. OK. just one last last thing. Efqan, Mesele dusturda deyil meni sehv basa dushme. neyse. bakiya ne vat gelirsen? gelde heftesonlari. Vaxt olan kimi gelecem. salam bu efgandi menem celil mene sum programina komek et.Xais edirem.Gozleyirem.saq ol.Sene ugurlar. Check is your sorting is stable i do to input this
Function Key:char; var c:char; begin; if not eof then read(c) else cor:=false; key:=c; end; but i have WA 1 when i write first test in my own my program output 'YES' What shall i do to realize input correct P.S. I read FAQ, it didn't help me in my problem Edited by author 21.02.2008 23:54 Edited by author 21.02.2008 14:59 can somebody please tell me how format of output should be?? thanks.. put spaces at the three lines of the output alex ;) I figured it out long back..thanks anyway the best way is to copy part of text from the web. It really works :) Edited by author 21.02.2008 04:09 Edited by author 21.02.2008 04:09 in example writen--- "Look for second hamburger at computer and chairs.790 " there mustn't writen "790". number of "<" is bigger than answer. and why "790" in the end of sentence!! pls, explain it to me!!! thx!!! and i think it is right!! program Project1094; {$APPTYPE CONSOLE} uses SysUtils; var a : string[80]; i, j : integer; ch : char; f, f1 : textfile; begin assign(f, '1094.in'); assign(f1, '1094.out'); reset(f); rewrite(f1); i := 0; fillchar(a, sizeOf(a), 0); while not eof do begin read(ch); if ch = '>' then begin if i < 80 then begin inc(i); a[i] := ' '; end else i := 0; end; if (ch = '<') and (i > 0) then dec(i); if (ch <> '<') and (ch <> '>') then begin inc(i); a[i] := ch; end; end; for j := 1 to i do write(a[j]); close(f); close(f1); end. Edited by author 20.02.2008 23:05 {$APPTYPE CONSOLE} {$n+} uses SysUtils; type tpoint=record x,y:{longint} extended; end; const maxn=200; var a:array[1..maxn] of tpoint; n:longint; min:extended; f:tpoint; procedure init; var i:longint; begin assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output); readln(f.x,f.y,n); for i:=1 to n do readln(a[i].x,a[i].y); inc(n); a[n+1].x:=a[1].x; a[n+1].y:=a[1].y; min:=maxlongint; end; function scalmul(p1,p2,p3,p4:tpoint):extended; begin scalmul:=(p2.x-p1.x)*(p4.x-p3.x)+(p2.y-p1.y)*(p4.y-p3.y); end; function rast(p1,p2:tpoint):extended; begin rast:=sqrt(sqr(p2.x-p1.x)+sqr(p2.y-p1.y)); end; function vecmul(p1,p2,p3,p4:tpoint):extended; begin vecmul:=(p2.x-p1.x)*(p4.y-p3.y)-(p2.y-p1.y)*(p4.x-p3.x); end; function prov:boolean; var i,j:longint; b:boolean; begin b:=true; for i:=1 to n-1 do if vecmul(a[i],f,a[i],a[i+1])>=0 then begin if b then b:=false; end; prov:=b; end; procedure solve; var i,j,im,l,r:longint; h:extended; begin if prov then begin writeln(0.0:0:3); halt; end; dec(n); for i:=1 to n do if rast(f,a[i])<min then begin min:=rast(f,a[i]); im:=i; end; l:=i-1; r:=i+1; if l<1 then inc(l,n); if r>n then dec(r,n); if (scalmul(a[l],f,a[l],a[im])>0) and (scalmul(a[im],f,a[im],a[l])>0) then begin h:=vecmul(f,a[im],f,a[l])/rast(a[im],a[l]); if min>h then min:=h; end; if (scalmul(a[r],f,a[r],a[im])>0) and (scalmul(a[im],f,a[im],a[r])>0) then begin h:=vecmul(f,a[im],f,a[r])/rast(a[im],a[r]); if min>h then min:=h; end; end; procedure done; begin writeln(abs(min*2):0:3); end; begin init; solve; done; end. in 4 test answer 0.000 (100%)(так что думай) yeah I have writtln 0 and I got WA at #4test then i wrote 0.000 and got AC I didn't understand where was the mistake in the code... if you have true code can you send me it on my e-mail, please? my e-mail : liwang@mail.ru I can send you any code if I have solved it. don't look to my account. just send me the number that you want. if I have it I will send you in return for this problem. thank you |
|