it's my code: ------------------------------ {deleted} ------------------------------ Edited by author 09.12.2006 21:18 i find my mistake #include<iostream> #include<math.h> int main() { using namespace std;
long j=1,k,R,L; double s,pi=3.1415926535; cin>>L>>R; if(L>=2*R) s=pi*R*R; else if (R>(L*sqrt(2.0))/2) s=L*L; else s=2*R*R*atan((L*L-2*R*R)/(L*sqrt((double) 4*R*R-L*L)))+L*sqrt((double) 4*R*R-L*L);
k=s;
while(k>10) { k=k/10; j++; } cout.precision( 3+j ); cout << noshowpoint << s << endl;
return 0; } Помоги мне . . . Edited by author 10.12.2006 01:07 program _1084; {$APPTYPE CONSOLE} uses SysUtils,math; const pi=3.1415926535; Var x,l,s,c:real; begin Readln(x,l); X:=x/2; c:=x*sqrt(2); if l>=c then s:=4*x*x; if l<=x then s:=pi*l*l; if not((l>=c)or(l<=x)) then Begin s:=8*(x*sqrt(l*l-x*x)/2+l*l/2*(pi/4-arccos(x/l))) end; writeln(s:0:3); end. program _1084; {$APPTYPE CONSOLE} uses crt; const pi=3.1415926535; Var x,l,s,c:real; begin Readln(x,l); X:=x/2; c:=x*sqrt(2); if l>=c then s:=4*x*x; if l<=x then s:=pi*l*l; if not((l>=c)or(l<=x)) then Begin s:=8*(x*sqrt(l*l-x*x)/2+l*l/2*(pi/4-arccos(x/l))) end; writeln(s:0:3); end. Edited by author 24.11.2007 16:45 Edited by author 24.11.2007 16:45#include<iostream> #include<fstream> #include<sstream> #include<vector> #include<cmath> #include<queue> #include<string> #include<iomanip> using namespace std; int main(){ //1084 double glength,r; double pi = 3.1415926535897932384626433832795; cin>>glength>>r; cout<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(3); if(glength >= r * 2.0){ cout<<r*r*pi<<endl; return 0; } if(glength * pow(2.0,0.5) <= r){ cout<<glength*glength<<endl; return 0; } else{ double d = pow((pow(r,2.0) - pow(glength/2.0,2.0)),0.5); double area = glength/2.0 * d/2.0; double arc = pi/4.0 - acos(0.5*glength/r); cout<< 8.0*(0.5*arc*r*r+area)<<endl; return 0; } } #include<iostream.h> #include<math.h> int main() { double pi; double l, r,alpha,segm,treug,delta; cin>>l>>r; pi=3; l/=2; if(r<=l/2) cout<<pi*r*r; if(r>(l*sqrt(2))) cout<<l*l*4; else { alpha=2*acos(l/r); segm=pi*r/(2*alpha); treug=l*sqrt(((r*r)-(l*l))); delta=segm-treug; cout<<pi*r*r-4*delta; } return 0; } Sorry pi=3,145 Why when inpus is: 3 1 Output is: -1.#IND ??? Compiler: Visual C++ 6.0 #include<stdio.h> #include<math.h> #define pi 3.14159265 int main() { int l,r; double result,angle; scanf("%d%d",&l,&r); if((double)l-sqrt(2)*r<1e-6) result=1.0; else if((double)l/2.0-(double)r>-1e-6) result=pi*r*r/(double)(l*l); else { angle=acos(l/2.0/r); result=((pi-4*angle)*r*r+2*l*r*sin(angle))/(double)(l*l); } printf("%.3lf\n",result*100.0); return 0; } SO DO I : #include <stdio.h> #include <math.h> int main() { double rect,r,piedeg,area=0,theta; scanf("%lf %lf",&rect,&r); if(rect>=(r*2)){ printf("%.3lf",3.1415926535*r*r); } else if(((rect*sqrt(2))/2)<=r){ printf("%.3lf",rect*rect); } else{ rect=rect/2; theta=acos(rect/r); piedeg=(2*3.1415926535)-(8*theta); area=(piedeg*3.1415926535*r*r)/ (2*3.1415926535); area=area+(tan(theta)*rect*rect*4); printf("%.3lf",area); } return 0; } IT GOT CE , PLS HELP sqrt(2)=>sqrt(2.0) ||sqrt((double) 2); const p=3.1415926535897932384626433832795; var arccos,x,as,at,ah,a,b,l,r:real; begin read(l,r); if r>=l*sqrt(2) then writeln(l*l:0:3) else if r<=l / 2 then writeln(p*r*r:0:3) else begin x:=l/(2*r); b:=l/2; ArcCos := ArcTan (sqrt (1-sqr (x)) /x); as:=arccos*r*r; at:=b*sqrt(r*r-b*b); ah:=as-at; a:=p*r*r; a:=a-4*ah; writeln(a:0:3); end; end. i tested it with BP 7.0 and FP 1.0.10 both on windows... what's wrong? 754129 18:57:25 7 фев 2005 TECTOBOP 1084 Pascal Wrong Answer 6 0.015 143 КБ 1.'as' is keyword like 'while' or 'if' 2.to have AC 'if r>=l*sqrt(2) then' ---> 'if r>=l*sqrt(2)/2 then' I am solving this problem with recursion. I divide square into 4 peaces and recurse on them, if they are in circle. so on... but I got Wrong Answer on 7 test. can you send me sophisticated tests. and tell me your algorith too. simple formula... like this:2R^2*arctg((L^2-2R^2)/(L*sqrt(4R^2-L^2)))+L*sqrt(4*R^2-L^2) well, this is only for when they intersect, else there is pi*r^2 or L^2 Thanks I'll look at this formula where did you get this formula. I wonna get THis Book simple formula... like this:2R^2*arctg((L^2-2R^2)/(L*sqrt(4R^2-L^2)))+L*sqrt(4*R^2-L^2) well, this is only for when they intersect, else there is pi*r^2 or L^2 I deducted that formula :) Imagine that! You are very intelligent men It is not too hard to get this formula by drawing a circle inside a rectangle on paper and thinking about it little I got wrong 7 test like you. Now I got AC. You must give value of pi equal 3.1415926535. I think it will AC. if you use #include<math.h> you get CE if you use sqrt(2);//or any other integer in C++ use sqrt(2.0); //sqrt(2); ==> COMPILATION ERROR in C it is ok to use sqrt(2); I hope I helped you.. Good luck and Have fun ! :D Yeah! You help, it's right!!! I'm tired from CE... but sqrt(2.0) - accepted!!! gl hf bb #include <stdio.h> #include <math.h> void main(){ double r,a,s,angl,cosa; scanf("%lf %lf",&a,&r); if (2*r<a) s=M_PI*r*r; else if (sqrt(2)*r>a) s=a*a; else{ cosa=a/(2*r); angl=2*acos(cosa); angl=M_PI/2-angl; s=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2; } printf("%.3lf\n",4*s); } > #include <stdio.h> > #include <math.h> > void main(){ > double r,a,s,angl,cosa; > scanf("%lf %lf",&a,&r); > if (2*r<a) s=M_PI*r*r; > else if (sqrt(2)*r>a) s=a*a; > else{ > cosa=a/(2*r); > angl=2*acos(cosa); > angl=M_PI/2-angl; > s=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2; > } > printf("%.3lf\n",4*s); > } i think my reply was too late. but for other people. when using sqrt(2) or something which arguments are not integer, you should use -> sqrt(2.0) instead. sqrt(2) ==> sqrt(2.0) Thank you very much!!! I'd reciiving :"compilation error"... But now all O.K.! )) #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { long double x,y; cout <<setprecision(3)<<fixed<<showpoint; const long double pi=3.1416; cin >>x>>y; if(x/2<y) { if(sqrt(2.0)*x<=y) cout <<x*x<<endl; else { cout <<y*y*pi-(y*y*acosl(x/2/y)-sqrtl(y*y-x*x/4)*x/2)*4 <<endl; } } else cout <<y*y*pi<<endl; //system("pause"); return 0; } //There seams to be a problem with your C++ compiler. //It doesn't support #include<math.h> //In many problems I tried to use MATH.H, but I always got //COMPILATION ERROR. //Please take my notice into consideration and fix, if //possible, the problem. Thank you. I solved the problem. :D Look at my other post to see the solution. :D Edited by author 09.04.2005 15:27 Edited by author 10.04.2005 17:21 You got CE, because, maybe your code have the next lines: #include <math.h> ... int n; ... sqrt(n); ... if you change sqrt(n); to sqrt((double)n); You will not get CE! Sorry for my poor English :) I don't have any integer variables. (int n) I use float. float n; sqrt(n); I tried also with double n; but I still get compilation error. Send me your source to victorbarinov@ua.fm If you know Russian language, say please. Bue! I sent you an email containing my code. Please take a look. I'm sorry but I don't know Russian. My email is danmana11@yahoo.com If you not recieve my letter... change sqrt(2) to sqrt(2.0) in C 2 - integer value 2.0 - double value Thank you very much I got AC. I was able to get AC other problems in witch I had the same error. I also got AC with the same code, but in C (with sqrt(2)). It seams that only C++ has this problem. So my conclusion : in C++ use sqrt(2.0); //sqrt(2); produces CE in C it is ok to use sqrt(2); Thank you very much for your help. :D give us your formulas and we'll watch them^) r:real; writeln (r:3:3); IS THIS GOD OR NOT #include<stdio.h> #include<math.h> void main() { double a,b,s; scanf("%lf%lf",&a,&b); if((a==0)||(b==0)){ s=0; printf("%.3lf",s); return; }else if(b-1.4142*a>=1e-4){ s=a*a; }else if(b-a/2<=1e-4){ s=3.1416*b*b; }else{ double alfa=2*acos(a/(2*b)); double s1=b*b*alfa/2-b*b*sin(alfa)/2; s=3.1416*b*b-4*s1; } printf("%.3lf\n",s); } I think there is something error in the math.h of this problem. So I had to use integral to do it. :( Can you use Dephi??????????? Or Pascal...... It's more easy to slove this problem. ok,i havent seen your prog clearly David Why do you use 'uses math'? uses math; const p=3.14; { -> p = pi , it will more accurate} var a,r:integer; s,angl,cosa:real; begin readln (a,r); if (2*r<a) then s:=p*r*r else if (sqrt(2)*r>a) then s:=a*a else begin cosa:=a/(2*r); angl:=2*arctan(cosa); angl:=p/2-angl; s:=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2; s := s * 4; end; writeln (s:10:3); end. Oh my friend.Even though I try my best. I still get 10 WA before I got AC with your program 8::::( What a hard work....:-) First of all I use p=3.1415926535897 .......A terrible number, isn't it? Then if (2*r<a) ==> if (2*r<=a) if (sqrt(2)*r>a) ==> if (sqrt(2)*a/2<r) then angl:=2*arctan(cosa); ==> angl:=2*arccos(cosa); writeln (s:10:3); ===> writeln (s:0:3); Good luck next time. By the way .I send a E-mail to you . Reply it Ok?????? > By the way my E-mail is fc_rainofstar_@163.com Send a E-mail to me Ok? uses math; const p=3.14; var a,r:integer; s,angl,cosa:real; begin readln (a,r); if (2*r<a) then s:=p*r*r else if (sqrt(2)*r>a) then s:=a*a else begin cosa:=a/(2*r); angl:=2*arccos(cosa); angl:=p/2-angl; s:=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2; end; writeln (s*4:3:3); end. I've solved the problem but it returns me "Wrong Answer" I've checked my answers on my PC and everything was correct! So please tell me how exactly to write the input and output. > So please tell me how exactly to write the input and output. Look, here's my C++ code: // @JUDGE_ID: 10231XX C C++ #include <stdio.h> #include <math.h> double R, H; double calculate() { /*.........*/ } int main() { scanf("%lf%lf",&H,&R); printf("%.3lf\n", calculate()); return 0; } |
|