Problem X
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 19 Accepted Submission(s) : 4
All K (1 ≤ K ≤ 1,000) of the cows are participating in Farmer John's annual reading contest. The competition consists of reading a single book with N (1 ≤ N ≤ 100,000) pages as fast as possible while understanding it.
Cow i has a reading speed Si (1 ≤ Si ≤ 100) pages per minute, a maximum consecutive reading time Ti (1 ≤ Ti ≤ 100) minutes, and a minimum rest time Ri (1 ≤ Ri ≤ 100) minutes. The cow can read at a rate of Si pages per minute, but only for Ti minutes at a time. After she stops reading to rest, she must rest for Ri minutes before commencing reading again.
Determine the number of minutes (rounded up to the nearest full minute) that it will take for each cow to read the book.
题意:一头年每分钟读s页,每连读T分钟休息R分钟,求最小多长时间读完这本书
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int n,m,a,b,c;
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
scanf("%d%d%d",&a,&b,&c);
int page=n;
int minute=0;
while(page>(a*b)) //当连读b分钟仍然小于剩余页数
{
minute=minute+b+c;
page-=a*b;
}
minute+=page/a;//剩余的页数
if(page%a>0)
minute++;
printf("%d",minute);
}
return 0;
}