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

Re:关键是那个取整的问题,看看我的!

Posted by ngn999 at 2008-07-25 18:46:30 on Problem 3619
In Reply To:郁闷!为何WA,知道的发站内邮件给我,谢谢 Posted by:jordankan at 2008-07-09 15:56:13
#include <stdio.h>

int main(){
	int n, k;
	int i;
	int time;
	int s,t,r;

	scanf("%d%d",&n,&k);
	for(i = 1; i <= k;i++){
		time = 0;
		scanf("%d%d%d", &s,&t,&r);

		if(n%(s*t) == 0)
			time = n/(s*t) * (t+r) - r;
		else if(n % (s * t) % s != 0) 
			time = n / (s*t) * (t+r) + (int)(n%(s*t)/s) + 1;
		else   ///刚好为整分的最时候,不能加1!
			time =  n / (s*t) * (t+r) + (int)(n%(s*t)/s);
		printf("%d\n",time);
	}
	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