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

WA了,大伙说的我都注意了,为什么还错呢?求解释!!!

Posted by 771385494 at 2011-11-28 15:16:03 on Problem 2163
#include <iostream>
using namespace std;
int main()
{
	int n,m,k,i,j,buy = 0;
	double pi[10000],pi_m = 0,pi_n = 0;
	cin >> m >> n >> k;
	for(i = 1;i <= k;i++)
		cin >> pi[i];
	for(i = n;i <= k;i++){
		double sum_m = 0,sum_n = 0;
		int count = i;
		for(j = 0;j < m;j++)
			sum_m += pi[count--];
		sum_n = sum_m;
		for(j = m;j < n;j++)
			sum_n += pi[count--];
		pi_m = sum_m * 1.0 / m;
		pi_n = sum_n * 1.0 / n;
		if(pi_m > pi_n && buy == 0){
			cout << "BUY ON DAY " << i << endl;
			buy = 1;
		}
		else if(pi_m <= pi_n && buy == 1){
			cout << "SELL ON DAY " << i << endl;
			buy = 0;
		}
	}
	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