POJ 3427 Ecology tax
来源:互联网 发布:excel03版数据分析表 编辑:程序博客网 时间:2024/05/22 12:54
http://poj.org/problem?id=3427
Description
In a big and rich on natural resources country, the government started a campaign to control deforestation. In fact the government is not too interested in how many trees get fallen, but rather how effectively the wood is utilized. So a law was passed which requires every logging company to pay amount of money in proportion to amount of wood that it wastes during operation.
A felling quota on some territory was allotted to a company in this country. Company lorries may only transport logs of exactly L meters long. So when a tree gets sawed into logs, the remainder is wasted.
Trees in this country grow exactly 1 meter per year, so the company may decrease the amount of tax to be paid by simply waiting for some years. Your task is to determine the number of years needed to achieve smallest possible tax. If there is more than one answer, find minimal (earliest) one.
Input
Input file contains number of trees N, length of log L, followed by integers i1 i2 ... iN — heights of each tree.
Constraints
1 ≤ N ≤ 30000, 1 ≤ L, ik ≤ 30000
Output
Output file must contain single integer — number of years to wait.
Sample Input
Sample Input 13 1 10 15 11Sample Input 23 25 3 6
Sample Output
Sample Output 10Sample Output 21
Hint
Bold texts appearing in the sample sections are informative and do not form part of the actual data.
Source
#include<iostream>
using namespace std;
int max(int a, int b){
return a > b ? a : b;
}
int main(){
int tree, len;
while(cin >> tree >> len){
int hei, ans = 0;
while(tree --){
cin >> hei;
if(hei % len == 0) continue;
ans = max(ans, len - hei % len);
}
cout << ans << endl;
}
return 0;
}
- POJ 3427 Ecology tax
- poj 3427 Ecology tax
- poj 3427 Ecology tax
- POJ 3427 Ecology tax G++
- POJ 3427 Ecology tax(水题)
- POJ 3427 Ecology tax(水~)
- POJ 3427 Ecology tax(我的水题之路——不同的理解,不同的AC)
- Land Division Tax - POJ 2086 dp
- poj3427Ecology tax
- ofbiz tax
- 避税Tax shelter
- 物业税 property tax
- Individual Income Tax(个人所得税)
- Tax module in Magento
- Contract,tax and banking
- 税盾(Tax Shield)
- Estimate Shipping and Tax
- Estimate Shipping and Tax
- 网络编辑如何为文章选择合适的关键字?
- 怎样在页面弹出文件保存框?
- Objective-C @property & @synthesize 使用
- QXDM的使用
- php
- POJ 3427 Ecology tax
- MKMapView用法
- stdarg.h的介绍(转)
- eclipse @override 报错 解决
- E4X教程[5] - 全局 XML 对象
- .net如何读取PDF文档的内容
- 在web页面实现flash播放pdf,word文档等(asp.net c#+flash Paper+SWFTools)
- 在web页面实现flash播放pdf,word文档等(asp.net c#+flash Paper+SWFTools)
- 在web页面实现flash播放pdf,word文档等(asp.net c#+flash Paper+SWFTools)