UVa 10465 Homer Simpson:枚举

10465 - Homer Simpson

Time limit: 3.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_problem&problem=1406

这数据量。。枚举绝对是最快的方式了。

完整代码:

/*0.025s*/

#include<bits/stdc++.h>
using namespace std;  

int main()
{
    int m, n, t, x, ans1, ans2, drink, i, k;
    while (~scanf("%d%d%d", &m, &n, &t))
    {
        if (m > n) swap(m, n);
        x = t / m, drink = -1u>>1;
        for (i = x; i >= 0 && drink; --i)///枚举
        {
            k = t - i * m;
            if (drink > k % n) drink = k % n, ans1 = i + k / n;///drinks as little beer as possible
            if (k % n == 0) ans2 = i + k / n;
        }
        if (drink) printf("%d %d\n", ans1, drink);
        else printf("%d\n", ans2);
    }
    return 0;
}

查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索http
, printf
, if
an d
10465 78 8、homer、pokerstarspokerhomer、捷信homer登陆、learn with homer,以便于您获取更多的相关知识。

时间: 2024-08-14 07:32:34

UVa 10465 Homer Simpson:枚举的相关文章

UVa 10167 Birthday Cake:枚举

10167 - Birthday Cake Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=107&page=show_problem&problem=1108 Background Lucy and Lily are twins. Today is their birthday. Mother buys a bir

UVa 140 Bandwidth:枚举全排列&amp;amp;剪枝搜索

140 - Bandwidth Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_problem&problem=76 Given a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and anord

UVa 10125 Sumsets (折半枚举&amp;amp;二分查找)

10125 - Sumsets Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1066 Given S, a set of integers, find the largest d such that a + b + c = d where a, b, c, and d are distinct elements of S

UVa 471 Magic Numbers:枚举

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=412 直接枚举.代码中给出了一个用位运算判断数字中是否有重复数字的方法. 完整代码: 01./*0.032s*/ 02. 03.#include <cstdio> 04.const long long maxn = 9876543210LL; 05.

UVa 1225 Digit Counting:枚举

1225 - Digit Counting Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=3666 N<10000,干脆O(NlogN)建表得了. 完整代码: /*0.012s*/ #include<cstdio> int c[10000]

UVa 10360 Rat Attack:枚举和优化

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1301 由于格子数远大于鼠窝,所以以鼠窝为出发点,增加鼠窝周围d范围内的"格子的值",最后扫描每个格子输出最大格子值即可. 完整代码: 01./*0.125s*/ 02. 03.#include<bits/stdc++.h> 04

uva 10730 - Antiarithmetic?

点击打开链接uva 10730 思路:枚举等差中项 分析: 1 给定一个n个数的序列判断是否有等差子序列 2 很明显我们如果要判断是否有等差子序列的话,只要去判断是否有长度为3的等差子序列 3 对于n<=10000,那么我们怎么去判断呢,由于我们要找的是是否有三个的等差序列,那么我们可以枚举每一个数作为等差中项,然后去判断 4 假设现在我们枚举num[i]作为等差中项,那么第一个数在0~i-1之间,第二个数是在i+1~n-1之间,这个时候如果单存利用for循环去找时间复杂度不能接受,那么我们想到

&amp;#106avascript对象和属性

对象 1.创建一个空对象:var o =new object();2.创建对象直接量:   var cricle={x:0,y:0,radius:2}   var homer={                        name:"Homer Simpson",                        age:34,                        married:true,                        email:"zzy@163

网页小知识:javaScript对象和属性

javascript|对象|网页 1.创建一个空对象:var o =new object();2.创建对象直接量:   var cricle={x:0,y:0,radius:2}   var homer={                        name:"Homer Simpson",                        age:34,                        married:true,                        email