https://vjudge.net/problem/UVA-1648

设上升x层,列个方程解出来,再把x带回去

#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int u[],d[];
int main()
{
int n,m,ans,x;
while(scanf("%d%d",&n,&m)!=EOF)
{
ans=2e9;
for(int i=;i<=m;i++) scanf("%d%d",&u[i],&d[i]);
for(int i=;i<=m;i++)
{
x=d[i]*n/(u[i]+d[i])+;
ans=min(ans,u[i]*x-d[i]*(n-x));
}
printf("%d\n",ans);
}
}

最新文章

  1. chrome浏览器 开发者工具简介
  2. 《Google软件测试之道》基础
  3. C语言实现冒泡排序-整数排序
  4. 由《win32多线程程序设计》临界区的问题所想
  5. curl返回常见错误码
  6. android 数据库的增删改查
  7. BZOJ2021: [Usaco2010 Jan]Cheese Towers
  8. Django学习笔记二
  9. Docker操作笔记(一)使用镜像
  10. MongoDB 简单操作
  11. SSM学习(一)Mybatis
  12. Mac安装python3.x+pycharm+elasticsearch+常见报错处理(1)
  13. python3对比python2的更新点
  14. 推荐一篇关于java集合的博文,写的很nice
  15. Jmeter学习——http请求Content encoding的重要性
  16. postgresql安装概览
  17. PTA第一个编程题总结
  18. Netflix分享构建Microservices的经验
  19. 50-用Python监听鼠标和键盘事件
  20. 第二章 flex处理二义性

热门文章

  1. HDU 3260/POJ 3827 Facer is learning to swim(DP+搜索)(2009 Asia Ningbo Regional)
  2. C语言文件基本操作
  3. “Hello World!”团队第三周召开的第五次会议
  4. mysql 只返回一条数据
  5. Python 服务器端表单验证插件
  6. 第一、二章——Python简介与Python基础
  7. SQL 单表分页存储过程和单表多字段排序和任意字段分页存储过程
  8. 【Linux】- Ubuntu安装redis,并开启远程访问
  9. IE8 兼容CSS3 使用 PIE.htc
  10. 能选择日期范围js控件