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 sunkt06 at 2008-07-31 16:42:06 on Problem 3619
In Reply To:Re:关键是那个取整的问题,看看我的! Posted by:ngn999 at 2008-07-25 18:46:30
> #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