杭电poj 3619 Speed Reading

Problem X

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 19   Accepted Submission(s) : 4
Problem Description

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.

 

Input
<p>* Line 1: Two space-separated integers: <i>N</i> and <i>K</i><br>* Lines 2..<i>K</i>+1: Line <i>i</i>+1 contains three space-separated integers: <i>S<sub>i</sub></i> , <i>T<sub>i</sub></i> , and <i>R<sub>i</sub></i> </p>
 

Output
<p>* Lines 1..<i>K</i>: Line <i>i</i> should indicate how many minutes (rounded up to the nearest full minute) are required for cow <i>i</i> to read the whole book.</p>
 

Sample Input
 
  
10 3 2 4 1 6 1 5 3 3 3
 

Sample Output
 
  
6 7 7
 

题意:一头年每分钟读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;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不会敲代码的小帅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值