Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:两个代码就是加1的位置不一样,为什么一个对一个错?

Posted by kimi940211 at 2014-02-23 22:00:38 on Problem 1423
In Reply To:两个代码就是加1的位置不一样,为什么一个对一个错? Posted by:kimi940211 at 2014-02-23 22:00:19
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator