|
|
Show all threads Hide all threads Show all messages Hide all messages | Page 1 | WA #7 | Petru Trimbitas | 1729. Dead Man's Chest | 7 Oct 2011 00:59 | 1 | WA #7 Petru Trimbitas 7 Oct 2011 00:59 here's my code. I've tried many testes but i've passed them\ #include <iostream> #include <iomanip> #include <cmath> using namespace std;
double f(double r, double a) { double rad=(a*4*atan((double)1))/180; double da=sqrt( 2*r*r-2*r*r*cos(rad) ); return da; }
int main() { double r,a,re,da,nr,rad; cin>>r>>a; re=r; nr=floor((double)180/a); da=f(r,2*a); re+=((nr-1)*da); double mod=360-floor(360/(2*a))*(2*a); //cout<<mod<<'\n'; if(mod) re+=f(r,mod); cout<<fixed<<setprecision(6)<<re; return 0; } | WA8 | XTender | 1729. Dead Man's Chest | 18 Apr 2010 20:57 | 1 | WA8 XTender 18 Apr 2010 20:57 Algorithm right, but what in 8 test? Please, give me test; | WA6 | Fyodor Menshikov | 1729. Dead Man's Chest | 1 Dec 2009 00:18 | 1 | WA6 Fyodor Menshikov 1 Dec 2009 00:18 Test is 10.000 29.999 Correst answer is 60.000583 | Hint | JIeHuH [Yaroslavl SU] | 1729. Dead Man's Chest | 24 Nov 2009 01:51 | 2 | Hint JIeHuH [Yaroslavl SU] 14 Nov 2009 11:23 For accuracy of calculations use power-reduction formulas /* 2 * sin ^ 2 (a) = 1 - cos(2a) */ in the formula that calculates chords long. Re: Hint JIeHuH [Yaroslavl SU] 24 Nov 2009 01:51 2 * R * sin( a / 2 ) = sqrt ( 2 R R 2 sin^2 ( a / 2 ) ) = sqrt ( 2 R R ( 1 - cos ( a ) ) = sqrt ( 2 R R - 2 R R cos ( a ) ) = sqrt ( R^2 + R^2 + 2 * R * R * cos ( a ) ) | WA 5 | Roland | 1729. Dead Man's Chest | 1 Dec 2009 00:17 | 4 | WA 5 Roland 18 Oct 2009 00:41 What is wrong? My answer is: ans=((int)(360/(2*a)-1))*2*r*sin((a*pi)/180)+r I HAVE THE SAME PROBLEM PLEASE HELP US.... My program is : #include<iostream> #include<cmath> #define PI 3.14159265358979323846264338327950288 using namespace std; double r,a,whole,reminder,side,leftSide; int main() { cin>>r>>a; whole=180/a; reminder=360-whole*(2.0*a); side=2*r*sin(a*PI/180); leftSide=2*r*sin(reminder*PI/360.0); printf("%.12lf",r+(whole-1)*side+leftSide); system("pause"); return 0; } Re: WA 5 Ras Misha [t4ce] 25 Oct 2009 16:42 you forget about last part for ex input 1 40 you have 3 part with arch = 80 degrees and last 40 degrees (not 80) SOrry for my english I hope that you understand Re: WA 5 Fyodor Menshikov 1 Dec 2009 00:17 Test 5: Input 10.000 30.001 Output 59.999698 | WA7, what wrong? | Dmitriy S. Hodyrev | 1729. Dead Man's Chest | 10 Jan 2010 10:10 | 8 | Many times my code was reviewed and rewatched, but still WA7. Could anybody help? What wrong with code? May be this algorithm gives not the optimal path? int main() { double r, a; std::cin >> r >> a; // first, walk to the edge of the island double s = r; // total angle of undiscovered edge const double a_left = 360.0 - 2.0*a; // hops count on 2*a "arc" line const int full_hops = (int)(a_left / (2.0*a)); s += range(r, to_rad(2.0*a)) * full_hops; // remaining angle to hop double a_rem = a_left - full_hops * (2.0 * a); s += range(r, to_rad(a_rem)); std::cout << std::fixed << std::setprecision(12) << s << std::endl; } Your algorithm allows me to AC. Maybe problem in calculations, in "to_rad" or "range"... I wrote to_rad and range to compile your code, and compared my code with yours: all output is identical. So, maybe you've mistook in one of these functions. Edited by author 18.10.2009 00:00 Thank you a lot for a great advice! Problem was eliminated after rewriting range() function: Old: used cosinus theorem New: using sinus to radius multiplication AC! Dmitriy S. Hodyrev! You solved 1726. If you read this, help me, please. My e-mail in my profile. Moders, sorry for the message concerning not this problem. But did you think about a functionality of allowing users to send private messages to the other users' e-mails through a web-form? Re: SuperLight 10 Jan 2010 10:10 I had the same problem: Since the cosine can be quite close to zero its square root is not calculated properly. So I also didn't use cosine theorem but calculated the length of the chords with simpler geometry: long double x = radius * cos(angle); long double y = radius * sin(angle); long double ans = sqrt((x - radius) * (x - radius) + y * y); Here the square root is done over the distance, not over the cosine, which, as it seems, solved the problem. Use the law of sines instead of cosines. | Why the answer is "6.000000"? (-) | Ivan | 1729. Dead Man's Chest | 21 Oct 2009 19:01 | 4 | path consist of 6 steps: 1) one step: from center to edge (1 meter) 2) five steps: counterclockwise along 60 degree arc (1 meter each) total 6 meters | >.< | testOrel | 1729. Dead Man's Chest | 17 Oct 2009 15:57 | 1 | >.< testOrel 17 Oct 2009 15:57 |
Pages: 1 |
|
|