|
|
Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | Hint. Some test :)++++++++++++ (+) | Виктор Крупко | 1302. Дельта-волна | 18 июн 2005 00:34 | 1 | 7 11 3 3 1 1 17 25 8 3 7 3 good luck!!!!!!! | Wa#7 Who can help me?Thanks! | Aarontony | 1302. Дельта-волна | 24 окт 2004 17:11 | 2 | WA#7 Here is my code: #include<stdio.h> #include<math.h> main() { long ans,x=0,y,i,j,k=0,l,m,n; scanf("%ld %ld",&m,&n); if(m>n){ans=m;m=n;n=ans;} for(i=0;i<=100009;i++) { if((m>i*i)&&(x==0)&&(m<=(i+1)*(i+1)))x=i+1; if((n>i*i)&&(k==0)&&(n<=(i+1)*(i+1)))k=i+1; if((x!=0)&&(k!=0))break; } y=m-(x-1)*(x-1);l=n-(k-1)*(k-1); if(m!=1)if(y%2==0)x=x*2-2;else x=x*2-1; if(l%2==0)k=k*2-2;else k=k*2-1; ans=fabs(k-x); y=(y+1)/2;l=(l+1)/2; if((l>=y)&&(l<=y+k-x))ans+=0;else { m=abs(l-y);n=abs(y+k-x-l); l=m>n?n:m; ans+=2*l; } printf("%ld\n",ans); return 0; } Give me your E-mail adress and i send you this test. | What is the answer for this tests? | Roman Lipovsky | 1302. Дельта-волна | 24 окт 2004 17:08 | 3 | What is the answer for this tests? 1) 1 999999999 2) 1 1000000000 3) 6564 842421 | Complete Error???????????where?where? | wangchun | 1302. Дельта-волна | 11 авг 2004 08:25 | 2 | var m,n,t,h,l,out:longint; as,bs:boolean; procedure check; var k,al,bl,ah,bh:longint; begin k:=1; while sqr(k)<m do inc(k); ah:=k; k:=1; while sqr(k)<n do inc(k); bh:=k; h:=bh-ah; al:=sqr(ah)-m-ah+1; bl:=sqr(bh)-n-bh+1; l:=abs(al-bl); if odd(sqr(ah)-m) then as:=false else as:=true; if odd(sqr(bh)-n) then bs:=false else bs:=true; end; procedure make; begin if as=bs then begin if l=0 then out:=h*2 else begin if l<=h then out:=2*h else begin out:=l+h; end; end; end else begin if as then begin if l>h then out:=l+h else out:=2*(h-1)+l; end else begin if l>h then out:=l+h else out:=2*h+1; end; end; writeln(out); end; begin readln(m,n); if m>n then begin t:=m; m:=n; n:=t; end; check; make; end. |
|
|
|