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 |
题不难,但因为一些细节WA了好多次,贴题留念#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator