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 了n次,谁能帮帮我 这是我的代码

Posted by banana at 2005-07-30 11:32:31 on Problem 2510
#include<iostream>
#include<string>
#include<iomanip>
#include<sstream>
using namespace std;
struct takein
{
	int type;
	double amount;
	double intime;
};
takein A[100];
int N = 0;
double cacu(double time);
int main()
{
	char temps[50];
	while(cin.getline(temps,50))
	{
		string ss;
		istringstream sin(temps);		
		sin >> ss;
		if(ss == "Query")
		{
			double t;
			sin>>t;
			cout<<setiosflags(ios::fixed)<<setprecision(0)<<t<<' ';
			double h = cacu(t);
			if(h<1.0) cout<<"1.0"<<endl;
			else cout<<setiosflags(ios::fixed)<<setprecision(1)<<h<<endl;
		}
		else
		{
			double time;
			double mou;
			if(ss=="Chocolate")
				A[N].type = 0;
			else A[N].type =1; 
			sin>>time>>mou;
			A[N].intime= time;
			A[N].amount=mou;
			N++;
		}
	}
	return 0;
}
double cacu(double time)
{
	int i;
	double res = 0.0;
	double ts;
	for(i = 0 ;i < N ;i ++)
	{
		if(A[i].type == 0) 
			ts = 8*A[i].amount - (time-A[i].intime)/12;
		else ts = 2*A[i].amount- (time - A[i].intime)*(time - A[i].intime)/79;
		if(ts<0)continue;
		else res+=ts;
	}
	return res;
}

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