Blinds(百叶窗)
来源:互联网 发布:智能手机加密软件 编辑:程序博客网 时间:2024/04/20 19:41
Description
The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they may not have the same length (it is even possible for them to have different lengths)
Every stripe can be cut into two or more parts. The cuttings are made perpendicularly to the side along which the length is measured. Thus the cuttings do not change the width of a stripe but each of the resulting pieces has a lesser length (the sum of which is equal to the length of the initial stripe)
After all the cuttings the blinds are constructed through consecutive joining of several parts, similar in length, along sides, along which length is measured. Also, apart from the resulting pieces an initial stripe can be used as a blind if it hasn’t been cut. It is forbidden to construct blinds in any other way.
Thus, if the blinds consist of k pieces each d in length, then they are of form of a rectangle of k × d bourlemeters.
Your task is to find for what window possessing the largest possible area the blinds can be made from the given stripes if on technical grounds it is forbidden to use pieces shorter than l bourlemeter. The window is of form of a rectangle with side lengths as positive integers.
Input
The first output line contains two space-separated integers n and l (1 ≤ n, l ≤ 100). They are the number of stripes in the warehouse and the minimal acceptable length of a blind stripe in bourlemeters. The second line contains space-separated n integers ai. They are the lengths of initial stripes in bourlemeters (1 ≤ ai ≤ 100).
Output
Print the single number — the maximal area of the window in square bourlemeters that can be completely covered. If no window with a positive area that can be covered completely without breaking any of the given rules exist, then print the single number 0.
Sample Input
Input
4 2
1 2 3 4
Output
8
Input
5 3
5 5 7 3 1
Output
15
Input
2 3
1 2
Output
0
Hint
In the first sample test the required window is 2 × 4 in size and the blinds for it consist of 4 parts, each 2 bourlemeters long. One of the parts is the initial stripe with the length of 2, the other one is a part of a cut stripe with the length of 3 and the two remaining stripes are parts of a stripe with the length of 4 cut in halves.
题意:就是给你n个横条,l是最小的,然后从l —— 横条中最大的,使次数*横条的值最大。
代码如下:
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>#include <math.h>using namespace std;int main(){ int n, l, a[101], tp[200]; while(~scanf("%d %d", &n, &l)) { int ant = 0, maxx = 0; for(int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); if(a[n - 1] < l) puts("0"); else { for(int i = l; i <= a[n - 1]; i++) { ant = 0; for(int j = 0; j < n; j++) { ant += (a[j] / i); } maxx = max(maxx, ant * i); } printf("%d\n", maxx); } } return 0;}
- Blinds(百叶窗)
- blinds
- 百叶窗
- <cf>Blinds
- codeforces_38C Blinds
- 百叶窗特效(用move.js库)
- 百叶窗特效(用move.js库)
- 百叶窗特效(用move.js库)
- cocos2dx shader -- Vol.1(灰度、流光、百叶窗)
- silverlight百叶窗
- 百叶窗特效
- 自定义控件Camera+Matrix实现3D旋转及百叶窗效果(雷惊风)
- Android魔法(第四弹)—— 一步步实现百叶窗效果
- 实现百叶窗效果图
- asp百叶窗实现
- flex 百叶窗效果
- flex百叶窗效果
- felx百叶窗效果
- Coursera公开课笔记: 斯坦福大学机器学习第七课“正则化(Regularization)”
- 关于语言
- iOS.swift textfield中光标初始位置
- UITableView的reloadData方法,不执行cellForRow方法,
- windows安装配置jdk1.8
- Blinds(百叶窗)
- ssh免密码登录
- 斯坦福大学机器学习第八课“神经网络的表示(Neural Networks: Representation)”
- Android K线图试水
- U盘安装win10
- iOS 实现多个按钮,点选一个其它都取消选中状态的最佳方法
- 关于C++运算符重载和友元的概念
- 数据库范式区别
- C#集合之STACK