题目链接

题意 :给你a,b,n,让你找出两个数x,y,使得n-(a*x+b*y)最小。

思路 : 分大小做,然后枚举a的倍数

 #include <stdio.h>
#include <string.h>
#include <iostream>
#define LL __int64 using namespace std ; int main()
{
LL a,b,n ;
while(~scanf("%I64d %I64d %I64d",&a,&b,&n))
{
if(a == )
{
printf("%I64d 0\n",n) ;
continue ;
}
if(b == )
{
printf("0 %I64d\n",n) ;
continue ;
}
bool flag = false ;
if(a < b)
{
swap(a,b) ;
flag = true ;
}
LL t = min(n/a,b) ,x;
LL minn = 999999999LL ;
for(int i = ; i <= t ; i++)
{
if((n - a * i) % b < minn)
{
minn = (n - a * i) % b ;
x = i;
}
}
if(!flag) printf("%I64d %I64d\n",x,(n-a*x)/b) ;
else printf("%I64d %I64d\n",(n-a*x)/b,x) ;
}
return ;
}

URAL 1430. Crime and Punishment(数论)的更多相关文章

  1. URAL 1430 Crime and Punishment

    Crime and Punishment Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  2. 1430. Crime and Punishment(枚举)

    1430 即使是枚举 也是有一定技术含量的 对于ax+by = n: 枚举max(a,b)中的系数 这样可以确定另一个 但问题是如何确定上限 假设max(a,b) = a,很显然是不会超n/a的 但这 ...

  3. URAL 1139 City Blocks(数论)

    The blocks in the city of Fishburg are of square form. N avenues running south to north and Mstreets ...

  4. ural 1356. Something Easier(数论,哥德巴赫猜想)

    1356. Something Easier Time limit: 1.0 secondMemory limit: 64 MB “How do physicists define prime num ...

  5. Elasticsearch查询

    Elasticsearch支持两种类型的查询:基本查询和复合查询. 基本查询,如词条查询用于查询实际数据. 复合查询,如布尔查询,可以合并多个查询, 然而,这不是全部.除了这两种类型的查询,你还可以用 ...

  6. 越狱Season 1-Episode 14: The Rat

    Season 1, Episode 14: The Rat -Michael: 24 hours from now, 24小时后 my brother is scheduled to die, sch ...

  7. SQLite 入门教程(一)基本控制台(终端)命令

    一.基本简介 SQLite 是一个自持的(self-contained).无服务器的.零配置的.事务型的关系型数据库引擎.因为他很小,所以也可以作为嵌入式数据库内建在你的应用程序中.SQLite 被应 ...

  8. SQLite 入门教程(一)基本控制台(终端)命令 (转)

    转于: SQLite 入门教程(一)基本控制台(终端)命令 一.基本简介   SQLite 是一个自持的(self-contained).无服务器的.零配置的.事务型的关系型数据库引擎.因为他很小,所 ...

  9. ES系列十、ES常用查询API

    1.term查询 { "query": { "term": { "title": "crime" } } } 1.1.指 ...

随机推荐

  1. each函数遍历select标签下的所有option选项

    如下: <select id="asd" name="sweet1"> <option value=1>--四川--</optio ...

  2. (转) Docker EE/Docker CE简介与版本规划

    随着Docker的不断流行与发展,docker公司(或称为组织)也开启了商业化之路,Docker 从 17.03版本之后分为 CE(Community Edition) 和 EE(Enterprise ...

  3. WebApi 返值的实体值前缀加了个下划线

    发现MODEL类中加了个可以被序列化的标记,把它去除即可. [Serializable]

  4. POJ1159解题心得

    题目:http://poj.org/problem?id=1159 刚开始,从样例的特征去思考.总让我从回文数的角度去思考,想出几个方案,可都用了数据去检验,发现不行.如:ABCDDCB,BACDCA ...

  5. node的调试

    /* * 在node中,提供了一个可以通过简单TCP协议来访问的调试器.可以使用node debug 文件名,当调试器可以使用之后,命令行窗口界面中出现一个debugger命令提示符.后跟ok文字.代 ...

  6. Angular2快速入门-4.创建一个服务(创建NewsService提供数据)

    上篇我们使用的数据是通过mock-news.ts中的const News[] 数组直接赋给Component 组件的,这篇我们把提供数据的部分单独封装成服务 第一.创建news.service.ts ...

  7. 为什么 ReactJS 不适合复杂的前端项目?

    问题一:ReactJS组件难以在复杂交互页面中复用 ReactJS中的最小复用单位是组件.ReactJS的组件比AngularJS的Controller和View 要轻量些. 每个组件只需要前端开发者 ...

  8. Mellanox infinoband RDMA SDP

    IPoIB Internet Protocol over InfiniBand 就是指利用物理IB网络(IB卡,线缆,交换机,更甚者IB3层交换)通过ip协议进行连接,并进行数据传输! SDP Soc ...

  9. 「小程序JAVA实战」小程序的表单组件(25)

    转自:https://idig8.com/2018/08/18/xiaochengxujavashizhanxiaochengxudebiaodanzujian25/ 来说下 ,小程序的基础组件.源码 ...

  10. tornado 自定义session (一)

    tornado 中没有session功能,需要我们自己实现. 目录: settings: settings = { 'template_path': 'templates', 'static': 's ...