HDU4519
一种比较挫的写法
/*
模拟
*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
using namespace std;
const int maxn = ; int cmp( int a,int b ){
return a>b;
} int main(){
int ca;
scanf("%d",&ca);
while( ca-- ){
int n,m,k;
scanf("%d%d%d",&n,&k,&m);
int a[ maxn ];
for( int i=;i<n;i++ )
a[i] = k;
int ans = ;
while( ){
sort( a,a+n,cmp );
if( a[]<= ) break;
for( int i=;a[i]>&&i<min(n,m);i++ )
a[ i ]--;
ans++;
}
printf("%d\n",ans);
}
return ;
}
另外一种方法
/*
模拟
*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
using namespace std;
const int maxn = ;
const double eps = 0.99999999; int main(){
int ca;
scanf("%d",&ca);
while( ca-- ){
int n,m,k;
scanf("%d%d%d",&n,&k,&m);
if( m>=n ){
printf("%d\n",k);
continue;
}
if( (n*k)%m== ) printf("%d\n",n*k/m);
else printf("%d\n",n*k/m+);
}
return ;
}
HDU4519的更多相关文章
- HDU----(4519)郑厂长系列故事——体检
郑厂长系列故事——体检 Time Limit: 500/200 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total S ...
随机推荐
- 介绍map.entry接口
Map是java中的接口,Map.Entry是Map的一个内部接口.java.util.Map.Entry接口主要就是在遍历map的时候用到. Map提供了一些常用方法,如keySet().entry ...
- ligerUI调用$.ligerDialog.open弹出窗口关闭
1:调用父窗口某一个文件框,获取焦点, parent.window.document.getElementById("roleName").focus(); 2:关闭父窗口 par ...
- ios Swift 备忘录
Variables var myInt = var myExplicitInt: Int = // explicit type var x = , y = , z = // declare multi ...
- SAX方式解析XML文件实例
books.XML文件: 书籍book.java实体类: public class Book { private String id; private String name; private Str ...
- JAVA调用WebService总结
一.wximport自动生成代码 wsimport -keep -p com.test.client http://localhost:8080/test/services/TestService?w ...
- MBR与分区表备份与恢复
常用工具列表 dd 数据复制,转换实用工具 tar GNU磁盘存档实用工具 cpio 数据存档实用工 ...
- iOS 获取系统相册数据(不是调系统的相册)
Framework:AssetsLibrary.framework 主要目的是获取到系统相册的数据,并把系统相册里的照片显示出来. 1.创建一个新的项目: 2.将AssetsLibrary.frame ...
- IOS开发之NSPredicate谓词的用法
编程的人员不管是上过大学还是从培训机构出来的或做后台的.前端的都应该SQL语句有所了解,我们知道,在SQL语句当中 where 条件表达式可以对二维关系表的数据做条件筛选.微软的C# .net中也实现 ...
- C# ACM poj1006
中国剩余定理 public static void acm1006(int a, int b, int c, int d) { * ; * ; * ; * * ; ) * z; ) * y; ) * ...
- VC++ CTime Format 详解
参考链接: VC++中CTime类Format参数详解 CTime/COleDateTime::Format方法的使用 http://stat.ethz.ch/R-manual/R-devel/lib ...