Codeforces Beta Round #5 Problem Solving report

Source: Internet
Author: User
Tags strlen cmath

The ancient competition topic is a bit poisonous ah.

CBR 5

A. Chat Server ' s outgoing traffic

Test instructions: A communication tool that supports adding people to delete, calculate the final traffic flow =sigma (per message length * online number and)



Violence can.

Because there are spaces in the middle of the information, you need to use Getline

#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
# include<cstring>
#include <ctime>
#include <algorithm>
#define for (i,j,k) for (  Register ll I=j;i<=k;++i)
#define DOW (i,j,k) for  (Register ll I=k;i>=j;--i)
#define LL Long Long
#define MK Make_pair
#define PB push_back
#define EPS 1e-8
#define PA pair<ll,ll>
# Define FIR First
#define SEC second
using namespace std;
inline ll read ()
{
    ll T=0,f=1;char C=getchar ();
    while (c< ' 0 ' | | C> ' 9 ')   {if (c== '-') F=-1;c=getchar ();}
    while (c>= ' 0 ' &&c<= ' 9 ') T=t*10+c-48,c=getchar ();
    return t*f;
}
int Now,ans;
Char s[200001];
int main ()
{
	now=0;
	while (Cin.getline (s,10001))
	{
		if (s[0]== ' + ') now++;else
		if (s[0]== '-') now--;else
		{
			int Len=strlen (s);
			for (I,0,len)	if (s[i]== ': ')	ans+= (len-1-i) *now;
		}
	}
	cout<<ans<<endl;
}


B. Center Alignment

Test instructions: The center of each string, if the left and right space can not be equal, the first to the left, the second to starboard ...

Test instructions Toxic ... Two times the wrong MMP.

Just messing around, or getline.

#include <iostream> #include <cstdio> #include <cmath> #include <queue> #include <cstring > #include <ctime> #include <algorithm> #define for (i,j,k) for (Register ll I=j;i<=k;++i) #define DOW (I, J,K) for (Register ll I=k;i>=j;--i) #define LL Long long #define MK Make_pair #define PB push_back #define EPS 1e-8 #de
Fine pa pair<ll,ll> #define FIR First #define SEC second using namespace std;
    inline ll read () {ll t=0,f=1;char C=getchar (); while (c< ' 0 ' | |
    C> ' 9 ') {if (c== '-') F=-1;c=getchar ();}
    while (c>= ' 0 ' &&c<= ' 9 ') T=t*10+c-48,c=getchar ();
return t*f;
} int n,mx,lres,rres;
int lef=1;
Char s[10001][1100];
	int main () {n=1;
	while (Cin.getline (s[n],1000)) n++;
	n--;
	for (i,1,n) Mx=max (MX, (int) strlen (s[i]));
	for (i,1,mx+2) putchar (' * ');p UTS ("");
		for (i,1,n) {int Len=strlen (s[i]);
		Lres= (Mx-len)/2;rres=mx-len-lres;
		if (lres!=rres) if (!lef) swap (lres,rres), Lef=1;else lef=0; Putchar (' * '); for (J,1,lres) Putchar (' ');
		for (j,0,len-1) Putchar (S[i][j]); for (J,1,rres) Putchar

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.