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 20121181jj at 2014-02-11 11:48:10 on Problem 2163
#include<iostream>
using namespace std;
int main(){
	int m,n,k,i;
	while(cin>>m>>n>>k&&m>=1&&n>m&&n<=100){
	  double p[10005]={0.00},pm[10005]={0.0},pn[10005]={0.0};
	  for(i=1;i<=k;i++) cin>>p[i];
	  for(i=n;i<=k;i++){
		for(int j=i-m+1;j<=i;j++) pm[i]+=p[j];
		for(int j=i-n+1;j<=i;j++) pn[i]+=p[j];
	  }
 	 for(i=n;i<=k;i++){
		if(pm[i]*n>pn[i]*m&&(i==n||pm[i-1]*n<pn[i-1]*m))
		  cout<<"BUY ON DAY "<<i<<endl;
		else if(pm[i]*n<pn[i]*m&&(i==n||pm[i-1]*n>pn[i-1]*m))
		  cout<<"SELL ON DAY "<<i<<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