CF93B.End of Exams
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Students love to celebrate their holidays. Especially if the holiday is the day of the end of exams!
Despite the fact that Igor K., unlike his groupmates, failed to pass a programming test, he decided to invite them to go to a cafe so that each of them could drink a bottle of... fresh cow milk. Having entered the cafe, the m friends found n different kinds of milk on the menu, that's why they ordered n bottles — one bottle of each kind. We know that the volume of milk in each bottle equals w.
When the bottles were brought in, they decided to pour all the milk evenly among the m cups, so that each got a cup. As a punishment for not passing the test Igor was appointed the person to pour the milk. He protested that he was afraid to mix something up and suggested to distribute the drink so that the milk from each bottle was in no more than two different cups. His friends agreed but they suddenly faced the following problem — and what is actually the way to do it?
Help them and write the program that will help to distribute the milk among the cups and drink it as quickly as possible!
Note that due to Igor K.'s perfectly accurate eye and unswerving hands, he can pour any fractional amount of milk from any bottle to any cup.
学生们喜欢庆祝他们的节日,尤其是考试结束日!
尽管伊戈尔·K. 与同班同学不同,未能通过一次编程考试,他仍决定邀请同学们一起去咖啡馆,让每人喝上一瓶……新鲜的牛奶。进入咖啡馆后,这 m 位朋友发现菜单上有 n 种不同的牛奶,于是他们点了 n 瓶——每种各一瓶。已知每瓶牛奶的体积均为 w。
当牛奶端上来后,他们决定将所有牛奶平均分到 m 个杯子中,使得每人恰好得到一个杯子。作为未通过考试的“惩罚”,伊戈尔被指定负责倒牛奶。他抗议道,自己担心搞混,因而建议采用如下分配方式:每瓶牛奶至多倒入两个不同的杯子中。朋友们同意了这一提议,但随即面临一个问题——究竟该如何实现这种分配?
请帮助他们编写一个程序,以完成牛奶在杯子间的分配,从而让大家尽快享用!
注意:由于伊戈尔·K. 拥有极其精准的目光与稳定的手,他能从任意一瓶中向任意一个杯子倾倒任意分数体积的牛奶。
输入格式
The only input data file contains three integers n, w and m (1 ≤ n ≤ 50, 100 ≤ w ≤ 1000, 2 ≤ m ≤ 50), where n stands for the number of ordered bottles, w stands for the volume of each of them and m stands for the number of friends in the company.
唯一的输入数据文件包含三个整数 n、w 和 m(1 ≤ n ≤ 50,100 ≤ w ≤ 1000,2 ≤ m ≤ 50),其中 n 表示已订购的瓶子数量,w 表示每个瓶子的容量,m 表示公司中朋友的数量。
输出格式
Print on the first line "YES" if it is possible to pour the milk so that the milk from each bottle was in no more than two different cups. If there's no solution, print "NO".
If there is a solution, then print m more lines, where the i-th of them describes the content of the i-th student's cup. The line should consist of one or more pairs that would look like "b v". Each such pair means that v (v > 0) units of milk were poured into the i-th cup from bottle b (1 ≤ b ≤ n). All numbers b on each line should be different.
If there are several variants to solve the problem, print any of them. Print the real numbers with no less than 6 digits after the decimal point.
如果可以将牛奶倒入杯子,使得每瓶牛奶最多只出现在两个不同的杯子中,则在第一行输出“YES”;否则输出“NO”。
如果存在解,则再输出 $ m $ 行,其中第 $ i $ 行描述第 $ i $ 位学生的杯子中的内容。该行应由一个或多个形如“b v”的数对组成。每个这样的数对表示从编号为 $ b ( 1 \leq b \leq n $)的瓶子中向第 $ i $ 个杯子倒入了 $ v ( v > 0 $)单位的牛奶。每行中所有 $ b $ 的值必须互不相同。
若存在多种可行方案,输出任意一种即可。输出的实数需保留不少于 6 位小数。
输入输出样例
输入#1
2 500 3
输出#1
YES 1 333.333333 2 333.333333 2 166.666667 1 166.666667
输入#2
4 100 5
输出#2
YES 3 20.000000 4 60.000000 1 80.000000 4 40.000000 2 40.000000 3 80.000000 2 60.000000 1 20.000000
输入#3
4 100 7
输出#3
NO
输入#4
5 500 2
输出#4
YES 4 250.000000 5 500.000000 2 500.000000 3 500.000000 1 500.000000 4 250.000000
输入解题思路,AI测评打分。不知道怎么写?