|
|
вернуться в форумWA #9!! What's the tricky test case here? WA #9!! What's the tricky test case here? Please help.. #include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { int side, cord; double alas, tinggi, bagi, cos_segi, luas1, luas2, maxCord, tembereng, luasAll; const double pi=3.1415926535897932384626433832795; cin>>side>>cord;
tinggi = (side/2); maxCord = tinggi * sqrt(2.0);
if(cord >= maxCord) luasAll = side*side; else if(cord <= tinggi) luasAll = pi*cord*cord; else { bagi = tinggi/cord; alas = 2*sqrt(cord*cord - tinggi*tinggi); cos_segi = acos(bagi); luas1 = alas*tinggi/2; luas2 = cos_segi/2*cord*cord; tembereng = 2*luas2 - luas1; luasAll = pi*cord*cord - 4*tembereng; } cout<<fixed<<showpoint<<setprecision(3); cout<<luasAll; return 0; } Edited by author 01.12.2008 11:01 |
|
|