Loading [MathJax]/extensions/TeX/AMSsymbols.js

2015年9月23日 星期三

UVa10221 Satellites

題目來源:https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1162

胡言亂語:

找弧長和弦長的公式找好久喔 ... 再次要在code book加上新東西了XD

這題我犯的錯誤是,忘記輸出小數點後6位,輸出小數的話用printf 比較好寫

double x;
printf("%.nlf",x);

這樣就可以輸出小數點後n位了。=)

程式碼:


#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
double s,a;
string str;
while(cin>>s>>a>>str){
if(str[0]=='m') a/=60;
if(a>180) a=360-a;
s+=6440;
printf("%.6lf %.6lf\n",a*acos(-1.0)/180.0*s,2.0*s*sin(a*acos(-1.0)/180.0/2.0));
}
}
view raw 001.cpp hosted with ❤ by GitHub



沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。