12325-zombie ' s treasure Chest.

Source: Internet
Author: User

Simple enumeration + clever evasion of large enumeration amount

#include <bits/stdc++.h>using namespace Std;long long N,s1,v1,s2,v2,total;int main () {Ios::sync_with_stdio (    FALSE);    Long Long t,maxn=0;    cin>>t;        while (t--) {cin>>n>>s1>>v1>>s2>>v2; total=0;        Long Long kase=0,money=0;        Long Long Q1=n/s1,q2=n/s2,q3=max (S1,S2);        Long Long Mincomplex=min (min (q1,q2), Q3);                if (MINCOMPLEX==Q1) {for (long long i=0;i<=q1;i++) {kase=n-i*s1;                money=i*v1+ (KASE/S2) *v2;            if (money>=total) Total=money;                }} else if (MINCOMPLEX==Q2) {for (long long i=0;i<=q2;i++) {kase=n-i*s2;                money=i*v2+ (KASE/S1) *v1;            if (money>=total) Total=money;                    }} else {if (s2*v1>s1*v2) {for (long long i=0;i<=s1-1;i++) {                    KASE=N-I*S2;                    money=i*v2+ (KASE/S1) *v1; if (MoNey>=total) Total=money;                    }} else {for (long long i=0;i<=s2-1;i++) {kase=n-i*s1;                    money=i*v1+ (KASE/S2) *v2;                if (money>=total) Total=money;    }}} cout<< "Case #" <<++maxn<< ":" <<total<< "\ n"; } return 0;}


12325-zombie ' s treasure Chest.

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.