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