# Codeforces Round #513 by Barcelona bootcamp (rated, div. 1 + div. 2)

Source: Internet
Author: User

A.phone Numbers

Test instructions: give you n number, each number can only be used at most once, ask you can make up to 8 of the number of 11-digit phone numbers are the number of

Idea: Simulation can be, note that the char array read-in is starting from 0 subscript (here is hack ... ）

`1#include <bits/stdc++.h>2 intMain ()3 {4     intn,num=0, ans=0;5     Charc[ the];6scanf"%d%s",&n,c);7      for(intI=0; i<n;i++)if(c[i]=='8') num++;//The original is from 1 to n ...8      while(num>0&&n>= One)9     {Tennum--; Onen-= One; Aans++; -     } -printf"%d\n", ans); the     return 0; -}`
View CodeB. Maximum Sum of Digits

Test instructions: Set a positive integer A, a and n, now given n, for each digit and the largest group (a, B), this and how much

Idea: Because it is to ask for each digit and, so specifically consider a specific number of segmentation, found that for a certain number of AI, regardless of how the points, whether borrow/be borrow, and are all AI, and the difference between the different methods is the reason whether borrow

This can be memory of DFS, set F (id,bor,now) to indicate to the ID bit, whether it is borrow (0,1), current digital and for now

Should pay attention to the borrow and not borrow the case of the decision (originally to consider less than borrow 9 can not borrow, was hack)

`1#include <bits/stdc++.h>2 using namespacestd;3 intans=0, a[ the]={0};4 intmark[ the][5][255]={0};5 intDfsintIdintBorintNow )6 {7     if(id==a[0]+1)8     {9ans=Max (ans,now);Ten         returnans; One     } A      -     if(mark[id][bor][now]!=-1)returnMark[id][bor][now]; -      the     inttmp=0; -     if(a[id]!=0) Tmp=max (Tmp,dfs (id+1,0, now+a[id]-Bor)); -     //Μ±ç°î»²»îªáãôò¿¼âç²»ïòïâò»î»½èî»µäçé¿ö£¨îª0ôò½èî»±øè»¸üóå£¬çò°üº¬áë±»½èî»µäçé¿ö£© -     if(id!=a[0]&& (! ( a[id]==9&&bor==0)) Tmp=max (Tmp,dfs (id+1,1, now+a[id]+Ten-Bor)); +     //¸ãî»öã²»îªxî¸ßî»çò²»îªã»±»½èî»¹ýµä9£¬ôò¿¼âçïòïâò»î»½èî» -     //ôà´éù¿¼âçáëã»óð½èî»¹ýµä9²»äü½èî» +      A     returnmark[id][bor][now]=tmp; at } - intMain () - { -     Long LongN; -scanf"%lld",&n); -      while(n) in     { -a[++a[0]]=n%Ten; toN/=Ten; +     } -memset (mark,-1,sizeof(Mark)); theDfs1,0,0); *printf"%d\n", ans); \$     return 0;Panax Notoginseng}`
View CodeC. Maximum Subrectangle

Test instructions

D. Social Circles

Codeforces Round #513 by Barcelona bootcamp (rated, div. 1 + div. 2)

Related Keywords:

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.