poj 3619 Speed Reading

Speed Reading

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8431   Accepted: 3935

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 ofSi 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

* Line 1: Two space-separated integers: N and K

* Lines 2..K+1: Line i+1 contains three space-separated integers: Si , Ti , and Ri

Output

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

Sample Input

10 3
2 4 1
6 1 5
3 3 3

Sample Output

6
7
7

题意:牛读一个厚度为n的书,每秒可以读s页,可以连续读t秒,不过读完t秒后必需要休息r秒的时间,求牛读完这本书所需的时间;

#include <iostream>
using namespace std;
int main(){
	int n,k,s,t,r;
	cin>>n>>k;
	for (int i=0;i<k;i++){
		cin>>s>>t>>r;
		int page=n;
		int time=0;
		while (page>s*t){
			time=time+t+r;
			page-=s*t;
		}
		time+=page/s;
		if (page%s)
			time++;
		cout<<time<<endl;
	}
	return 0;
}
时间: 2024-10-12 12:00:37

poj 3619 Speed Reading的相关文章

POJ 3619 Speed Reading(简单题)

[题意简述]:有K头牛,N页书,每次第i头牛每分钟只能读Si页书,连续读Ti分钟,之后休息Ri分钟.现在问我们第i头牛花费多少时间可以读完这N页书. [分析]:简单的模拟 //220K 32Ms #include<iostream> #include<cmath> using namespace std; int main() { double N,K,Si,Ti,Ri; cin>>N>>K; double a = N; for(int i = 0;i<

[ACM] poj 2017 Speed Limit

Speed Limit Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17030   Accepted: 11950 Description Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately

POJ 2017 Speed Limit (直叙式的简单模拟 编程题目 动态属性很少,难度小)

Speed Limit Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17578   Accepted: 12361 Description Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately

poj 2017 Speed Limit

Speed Limit Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17704   Accepted: 12435 Description Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately

Super Memory &amp; Reading Skills

Super Memory & Reading Skills 341views Zaid Ali Alsagoff (91 SlideShares) , e-Learning Manager at IMU Keynote Author Follow 0 16 7 0 Published on Apr 15, 2015 In this workshop at IMU (16/04/2015), we will explore various techniques to stimulate and e

整理——各种模板

便于考前用... 平时先囤着... hash                                                  ACM1996总决赛-10-20-30 extend euclid                                      poj 1061-青蛙的约会 拓扑排序                                              poj 1270-Following Orders dsu             

Swing-JTable检测单元格数据变更事件

在JTable的初级教程中往往会提到,使用TableModel的 addTableModelListener方法可以监听单元格数据的变更,在其事件处理函,数tableChanged中,可以通过e.getColumn(),e.getFirstRow(),e.getLastRow(),e.getType()来获取变更发生的位置和变更的类型(插入.更新或删除).然而该方法存在2个致命的问题: 1.双击单元格使其处于可编辑状态后,即使没有做出任何修改,当单元格失去焦点时,该事件将被激活. 2.通过该事件

JTable用法-实例

前几篇文章介绍了JTable的基本用法,本文实现一个简单的JTable,算是前文的一个总结,并造福供拷贝党们. Swing-JTable用法-入门 Swing-JTable的渲染器与编辑器使用demo Swing-JTable检测单元格数据变更事件 一.主要功能 1.数据的增删改: 2.渲染器:“Vegetarian”列存放布尔值,以checkBox形式显示:“Sport”列存放字符串,以comboBox形式显示: 3.编辑器:“Name”的编辑器实现一个按钮,按下时弹出对话框: 4.ToolT

第27本:《学得少却考得好Learn More Study Less》

第27本:<学得少却考得好Learn More Study Less> <学得少却考得好Learn More Study Less>这本书最早是从褪墨网站上看到的,crowncheng翻译了全文.这本书介绍了不少学习方法,非常适合在校的学生,原文的作者Scott Young在高中和大学的学习成绩很好,但花在学习上的时间并不太多. 全书一上来引入了Holistic(整体性学习方法)这个单词,用来与死记硬背(Rote Memorization)学习法相区别,书的第四部分为小结,所以主要