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 ...
随机推荐
- JS 乱记
JS 中不存在块级作用域,也就是说在全局作用域下 if ,for 语句中用 var 声明的变量是全局变量. JS 中浮点数运算的值为近似值,比如:0.1 + 0.2 不等于 0.3 ,所以避免使用浮点 ...
- asp.net导入2013版本的excel问题解决
net中导入2013excel的故障解决办法. 修改导入excel的连接字符串 string strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data ...
- IOS-7步学会用代理
代理:又叫委托 自己不能去办的事委托给别人去办 之前学过的 UIAlertView UITextField都是使用了代理 反向传值代理 代理Block 写代理的步骤 需要帮忙的人(请求帮代饭的人) 1 ...
- C# ACM poj1005
大水题呀 public static void acm1005(int n, float[,] a) { float pi = 3.1415926f, rr; int years; ; i < ...
- 【干货分享】.NET单元测试电子书
文章目录: 引言 书籍首页 书籍目录 备注 下载 回到顶部 引言: 平时没有项目压力时候,首先想到的是充电学习,要系统学习都会想到购买书籍,或者向同事借阅.买的书多了烦恼也来了,因为大学到现在5 ...
- Error 1937.An error occurred during the installation of assembly...
工具:Installshield 2008 任务: 1. 创建一个 Merge Module 工程, 在 Merge Module 中包含若干 dll, 在安装过程中,dll 会被安装到指定路径. 2 ...
- Apache Shiro入门实例
Shiro是一个强大灵活的开源安全框架,提供身份验证.授权.会话管理.密码体系. 1.先创建一个Maven项目 2.配置pom <project xmlns="http://maven ...
- PHP递归
<?php /** * Mr.xml * 处理无限级分类 */ class Category{ /** * [递归一维数组] * @param [type] $cate [传递一个数组$cate ...
- jQuery1.8以上,ajaxSend,ajaxStart等一系列事件要绑定在document上才有效果
jQuery1.8以上,ajaxSend,ajaxStart等一系列事件要绑定在document上才有效果
- thinkphp分页实现
以上为我对于thinkphp分页的实现效果,两种方法,一种调用公共函数中的函数方法(参考http://www.cnblogs.com/tianguook/p/4326613.html),一种是在模型中 ...