Codeforces Round #345

Source: Internet
Author: User

A Joysticks

Test instructions: About 2 of the discharge, charge 1, ask two duration of the longest is how much.

Water problem, note that when a, B is equal to 1, the direct game is over.

#include <cstdio>#include<iostream>#include<algorithm>using namespacestd;intb;intMain () { while(SCANF ("%d%d", &a,&b)! =EOF) {            intnum=0; if(a==1&&b==1) {printf ("0\n");  Break; }         while(a>0&&b>0){            if(a>b) Swap (A, a); A++;b-=2; //printf ("%d%d\n", A, b);num++; } printf ("%d\n", num); }return 0;}
View Code

B Beautiful Paintings

Two water, is a i+1 >a i the logarithm of the maximum number, so the actual only need to ask how many of the same value, and then use the total minus this value. The reason is, since we sort, it is best to be in accordance with the order from small to large, but there may be repeated, so do not meet the conditions, so to re-shoot separately, then and the front of the broken, so as long as the total minus the number of broken.

#include <cstdio>#include<cstring>#include<iostream>using namespacestd;inta[1005],k,n;intMain () { while(SCANF ("%d", &n)! =EOF) {memset (A,0,sizeof(a)); intnum=0; intmaxx=0;  for(intI=0; i<n;i++) {scanf ("%d",&k); A[K]++; if(A[k]>maxx) maxx=A[k]; }       //printf ("%d\n", Maxx);printf"%d\n", N-Maxx); }return 0;}
View Code

C Watchmen

Idea: Simple to xi=xj, only need to ask the situation of the yi=yj and the number of 22 combinations, and then subtract Xi=xj and Yi=yj in the case of the 22 combination mode. The map is used.

#include <cstdio>#include<cstring>#include<map>#include<iostream>using namespaceStd;typedefLong LongLl;map<pair<LL,LL>,LL>Map1;map<ll,ll>map2,map3;intMain () {intN;    LL A, B;  while(SCANF ("%d", &n)! =EOF)            {map1.clear ();            Map2.clear ();        Map3.clear ();  for(intI=0; i<n;i++) {scanf ("%i64d%i64d",&a,&b); Map1[make_pair (A, b)]++; Map2[a]++; MAP3[B]++; }        /*printf ("%d\n", Map1.size ());        printf ("%d\n", Map2.size ()); printf ("%d\n", Map3.size ());*/Map<pair<LL,LL>,LL>:: Iterator it1; LL sum=0;  for(It1=map1.begin (); It1!=map1.end (); it1++){            //if (it1->second!=1)sum+=it1->second* (it1->second-1)/2; //else sum++;} LL sum1=0; Map<LL,LL>:: Iterator it2;  for(It2=map2.begin (); It2!=map2.end (); it2++){                //if (it2->second!=1)sum1+=it2->second* (it2->second-1)/2; //else sum1++;} map<LL,LL>:: Iterator it3;  for(It3=map3.begin (); It3!=map3.end (); it3++){                //if (it3->second!=1)sum1+=it3->second* (it3->second-1)/2; //else sum1++;} printf ("%i64d\n", sum1-sum); }return 0;}
View Code

Not to be continued ~ After the question has not written ~orz

Codeforces Round #345

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.