博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Class(ACM ICPC 2008–2009, NEERC, Northern Subregional Contest)
阅读量:4205 次
发布时间:2019-05-26

本文共 2345 字,大约阅读时间需要 7 分钟。

ACM ICPC 2008–2009, NEERC, Northern Subregional ContestSt Petersburg, November 1, 2008Problem C. ClassInput file: class.inOutput file: class.outTime limit: 3 secondsMemory limit: 256 megabytesDr. Strange is a really strange lecturer. Each lecture he calculates class fullness and if it is small, hedecreases all semester grades by one. So the students want to maximize the class fullness.The class fullness is the minimum of row fullness and column fullness. The column fullness is themaximum number of students in a single column and the row fullness is the maximum number of studentsin a single row.For example there are 16 students shown on the left picture (occupied desks are darkened). The rowfullness of this arrangement is 5 (the 4-th row) and the column fullness is 3 (the 1-st, the 3-rd, the 5-th orthe 6-th columns). So, the class fullness is 3. But if the students rearrange as shown on the right picturethen the column fullness will become 4 (the 5-th column), and so the class fullness will also become 4.12341234561234123456The students of Dr. Strange need to know the arrangement that maximizes class fullness so they askyou to write a program that calculates it for them.InputThe first line of the input file contains three integer numbers: n, r and c — number of students, rowsand columns in the class (1 ≤ r, c ≤ 100, 1 ≤ n ≤ r × c).OutputThe first line of the output file must contain a single integer number — the maximum possible classfullness.The following r lines must contain the optimal student arrangement. Each line must contain a descriptionof a single row. Row description is a line of c characters either ‘‘.’’ or ‘‘#’’, where ‘‘.’’ denotes an emptydesk, and ‘‘#’’ denotes an occupied one. If there are multiple optimal arrangements, output any one.Exampleclass.in class.out16 4 6 4.####.#..####...#####.##
 
////  main.cpp//  160929////  Created by liuzhe on 17/3/30.//  Copyright © 2016年 my_code. All rights reserved.////#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;char s[105][105];int main( ){ freopen("class.in","r",stdin); freopen("class.out","w",stdout); int n,m,a; while(cin>>a>>n>>m) { int t = min(n,m); int x = (a+1)>>1; t = min(t,x); cout<
<

转载地址:http://yvali.baihongyu.com/

你可能感兴趣的文章
剑指Offer 二叉树的镜像
查看>>
剑指Offer 含有Min函数的栈
查看>>
Mybatis 主键配置
查看>>
JVM 参数使用总结
查看>>
剑指Offer 最小的K个数
查看>>
剑指Offer 调整数组顺序使奇数位于偶数前面
查看>>
剑指Offer SnakeNumber 蛇形填数
查看>>
剑指Offer TurnOnLight 开灯问题
查看>>
剑指Offer RotateArray 旋转数组的最小数字
查看>>
剑指Offer FindNumberMoreThanHalf 找出数组中出现次数超过一半的数字
查看>>
剑指Offer AccurateFactorial 计算精确的阶乘
查看>>
剑指Offer CalCarryBit 计算进位个数
查看>>
剑指Offer ReverseList 反转列表
查看>>
剑指Offer MergeOrderedList 合并两个排序的链表
查看>>
剑指Offer LevelTraversalTree 层序遍历二叉树
查看>>
IDEA Maven搭建的Web项目出现ClassNotFoundException
查看>>
TCP/IP 三次握手建立连接和四次挥手释放连接
查看>>
操作系统 大端和小端(Big endian and Little endian)
查看>>
C++ 内联函数
查看>>
算法 递归和循环的转换
查看>>