Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
两个代码就是加1的位置不一样,为什么一个对一个错?#include<iostream> #include<cmath> using namespace std; double e = 2.7182818284590452354, pi = 3.141592653589793239; int main() { int testnumber; cin >> testnumber; int i; for (i = 0; i < testnumber; i++) { int n; cin >> n; double m = log10(2 * pi*n) / 2.0 + n*(log10(n / e)) + 1; int answer = (int)m; cout << answer << endl; } return 0; } 上面是错的,下面是对的 #include<iostream> #include<cmath> using namespace std; double e = 2.7182818284590452354, pi = 3.141592653589793239; int main() { int testnumber; cin >> testnumber; int i; for (i = 0; i < testnumber; i++) { int n; cin >> n; double m = log10(2 * pi*n) / 2.0 + n*(log10(n / e)) ; int answer = (int)m; answer++; cout << answer << endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator