UVa 10465 Homer Simpson: Enumeration

Source: Internet
Author: User
Tags printf time limit

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

This amount of data. Enumerations are definitely the quickest way to go.

Complete code:

/*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)///enum  
        {  
            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;  
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.