CCF 201612-2 火车购票 JAVA
来源:互联网 发布:苏州软件开发公司 编辑:程序博客网 时间:2024/06/04 18:10
//转载自http://www.dongcoder.com/detail-242760.html
//看每行的剩余的票数是不是可以容纳当前的需求,否则从下一行开始,如果全都不能容纳,则分开插入在每行中
import java.util.Scanner;
public class Main {
public static int s[][]=new int[20][5];
public static int a[]=new int[20];
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i=0;i<a.length;i++)
a[i]=5;
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int no;
while(n>0){
no=in.nextInt();
int pos;
for(pos=0;pos<20;pos++){//如果有行剩下的票数够容纳当前
if(a[pos]>=no){
while(no>0){
a[pos]--;
no--;
System.out.print(pos*5+5-a[pos]+" ");
} break;
}
}
if(pos==20){//则插入在每行中
for(pos=0;pos<20;pos++){
while(no>0&&a[pos]!=0){
a[pos]--;
no--;
System.out.print(pos*5+5-a[pos]+" ");
}
}
}
System.out.println();
n--;
}
}
}
阅读全文
1 0
- CCF 201612-2 火车购票 JAVA实现
- CCF 201612-2 火车购票 JAVA
- CCF 201612-2 火车购票
- CCF 201612-2 火车购票
- CCF认证 201612-2 火车购票
- CCF火车购票JAVA答案
- CCF 火车购票(Java)
- CCF 20160902 火车购票 Java
- CCF 201609-2 火车购票
- CCF 201609-2火车购票
- CCF 201609-2 火车购票
- CCF 201609-2 火车购票
- CCF CSP 201609-2 火车购票(Java-100分)
- CCF 201612-2 火车购票(简单模拟)
- ccf竞赛之火车购票 java版
- CCF编程练习:火车购票(Java)
- CCF 火车购票 C++ 解题,java写
- CCF 2016 9-2 火车购票
- Spring 的 IOC 容器和SpringMVC 的IOC容器
- XYNUOJ 1259 找零钱—贪心算法
- React Native 报错误“Error watching file for changes: EMFILE”
- CSS 参考手册定期通过所有主流浏览器进行测试
- Codeforces Round #426 (Div. 2) The Bakery 线段树+dp
- CCF 201612-2 火车购票 JAVA
- 学而时习之,不亦说乎
- 安装Oracle中遇到的问题
- php安装redis扩展
- Number Transformation
- 机器学习精简教程之三——用scikit-learn求解多元线性回归问题
- 面向对象
- Java数组
- 课程大纲