Hacker Cup 2015 qualifying tournament

Source: Internet
Author: User

A: Exchange a number of two bits, ask to get the maximum and the smallest number is how much.

Water problem:

1 //File name:a.cpp2 //Author:darkdream3 //Created time:2015 January 10 Saturday 17:16 44 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long -  - using namespacestd; -LL a[ -]; - intT; in ll SP (LL I, LL J, ll TMP) - { to      intx = (tmp)/a[i]%Ten ;  +      inty = (tmp)/A[J]%Ten ; -      if(x = =0&& J = =T) the          returntmp; *      returnTmp-x * A[i]-y*a[j] + y *a[i] + x*A[j]; $ }Panax Notoginseng intcount (LL tmp) - { the   intnum =0 ;  +     while(TMP) A    { theNum + +; +Tmp/=Ten; -    } $    returnnum; $ } - intMain () { -    intT; thescanf"%d",&t); -a[1] =1; Wuyi     for(inti =2; I <= -; i++) the    { -A[i] = a[i-1]*Ten; Wu    } -     for(intCA =1; CA <= T; CA + +) About    { $ LL tmp; -scanf"%lld",&tmp); -LL mx =tmp; -LL mi =tmp; AT =count (TMP); +        for(inti =1; I <= T;i + +) the            for(intj = i +1; J <= T; j + +) -           { $LL now =SP (i,j,tmp); the             if(Now >mx) theMX =Now ; the             if(Now <mi) theMi =Now ; -           } inprintf"Case #%d:%lld%lld\n", ca,mi,mx); the    } the  About return 0; the}
View Code

B: give you n items, each item has three kinds of attribute values, ask to choose any of them, can make the final value to be determined

Solving ideas: Binary Enumeration

Problem Solving Code:

1 //File name:b.cpp2 //Author:darkdream3 //Created time:2015 January 10 Saturday 17:55 37 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long -  - using namespacestd; - intGA,GB,GC; - inta[ -],b[ -],c[ -]; in BOOLSolveintk) - { to    intt=0 ;  +    intTA,TB,TC; -TA = TB = TC =0 ;  the     while(k) *    { $       ifK2)Panax Notoginseng       { -Ta + =A[t]; theTB + =B[t]; +TC + =C[t]; A       } theK/=2; +T + + ;  -    } $   //<F5> printf ("%d%d%d\n", TA,TB,TC); $    if(Ta = = Ga && TB = = gb&& TC = =Gc) -    { -        return  1; the    } -    return 0 ; Wuyi } the intMain () { -   intT; Wuscanf"%d",&T); -    for(intCA =1; CA <= T; CA + +) About   { $scanf" %d%d%d",&ga,&gb,&Gc); -       intN; -scanf"%d",&n); -        for(intI=0; I < n;i++) A       { +scanf" %d%d%d",&a[i],&b[i],&c[i]); the       } -       intTotal = (1<< N)-1; $       intOK =0 ;  the        for(inti =0; I <= Total;i + +) the       { the          if(Solve (i)) the          { -OK =1;  in             Break; the          } the       } About       if(OK) theprintf"Case #%d:yes\n", CA); the       Elseprintf"Case #%d:no\n", CA); the   } + return 0; -}
View Code

C: give you a grid diagram, where each grid has walls, rotating body turrets,

Hacker Cup 2015 qualifying tournament

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.