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

这代码,我自己都不知道自己写的啥?要错就错,别来RUNTIME ERROR啊

Posted by dynamic_study at 2009-08-21 19:37:05 on Problem 3619 and last updated at 2009-08-21 20:04:02
#include<iostream>
#include<cmath>
using namespace std;
struct node
{
	int s;
	int t;
	int r;
	int time;
}a[1001];
int main()
{
	int n,k,i;
	int ys,sx,sj,mid;
	cin>>n>>k;
	for(i=0;i<k;i++)
		cin>>a[i].s>>a[i].t>>a[i].r;
	for(i=0;i<k;i++)
	{
		ys=n/(a[i].s*a[i].t); 
		sx=n%(ys*a[i].s*a[i].t); 
	    sj=ys*(a[i].r+a[i].t);  
        mid=ceil((double)sx/(double)a[i].s);
		sj+=mid;
		if(mid==0)
		 a[i].time=(int)(sj)-a[i].r;
		else
			a[i].time=(int)(sj);
	}
	for(i=0;i<k;i++)
	cout<<a[i].time<<endl;
}

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