Codeforces 349B Color The Fence greedy, thinking

Source: Internet
Author: User

1, Codeforces 349B Color the Fence

2, Link: Http://codeforces.com/problemset/problem/349/B

3. Summary:

Brush the fence. 1-9 each letter to the AI to paint, ask the maximum number of figures can be drawn.

Greed, but also a little test thinking.

#include <bits/stdc++.h>using namespacestd;#defineLL Long Long#defineINF 0x3f3f3f3fintMain () {intv,a[ the];  while(~SCANF ("%d",&v)) {intm=1;  for(intI=1; i<=9; i++) {scanf ("%d",&A[i]); if(A[m]>a[i]) m=i; }        intNUM=V/A[M];//Find out the maximum number of numbers        if(num==0) puts ("-1"); Else        {             for(intI=0; i<num;i++)//cycle num times, each output can get the largest one{v%=A[m];  for(intj=9; j>=m;j--)                {                    if((A[j]-a[m]) <=v) {//If the number is less than the remaining, the outputv-= (a[j]-a[m]); printf ("%d", J);  Break; }}} printf ("\ n"); }    }    return 0;}
View Code

Codeforces 349B Color The Fence greedy, thinking

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.