Codeforces 552 for the first time to be able to do all out DIV2 shed tears of moving ....

Source: Internet
Author: User

#include <iostream>
#include <cstdio>
using namespace Std;


/*b*/
/* Note To open Long integer type ... Nothing else to say.
/*
int main ()
{
A long long int m;
scanf ("%lld", &m);
if (m<10) {printf ("%d\n", m); return 0;}
Long long int n=m;
int q=0;
while (n)
{
N=N/10;
q++;
}//printf ("%d\n", Q);
Long long int sum=0;
A long long int w;
int i;
for (i=0;i<q-1;i++)
{
W=1;
for (int j=0;j<i;j++) w=w*10;
sum+= (i+1) * (9*W);
}
M=m-10*w;
m=sum+ (i+1) * (m+1);
printf ("%lld\n", m);
return 0;
}
*/

/*a*/
/* Test instructions difficult to understand, but a look at the hint will be .... No, it's hard to say.
/*
int main ()
{
int m; scanf ("%d", &m); int x[101][101]={0};
int a,b,c,d;
for (int i=0;i<m;i++)
{
scanf ("%d%d%d%d", &a,&b,&c,&d);
for (int j=b;j<=d;j++)
{
for (int w=a;w<=c;w++)
{
x[j][w]++;
}
}

}
int sum=0;
for (int i=0;i<=100;i++)
{
for (int j=0;j<=100;j++)
{
SUM+=X[I][J];
}
}
printf ("%d\n", sum);
}
*/

/*c*/
/* Use the power of the mass w as the weight to see if the quality of the object can be weighed,,,,, weights may be left right ...
The main thing is to think of the weight into the system, the goods into the system, each bit is either 0 (no weight) or 1 (with 1) or w-1 (with 1 left) * *
/*
int main ()
{
int m,n;
scanf ("%d%d", &m,&n);
while (n)
{
if (n%m==1) n--;
else if (n%m==0) n=n/m;
else if (n%m==m-1) n++;
else {puts ("NO"); return 0;}
}
Puts ("YES");
}
*/

/*d*/
/* Three points not collinear is a set of solutions */
/* Four seconds of time to give the acid,,,,, a little optimization is not 233333333*/
/*
int main ()
{
int a[2001][2];
int m;
scanf ("%d", &m);
int i,j;
for (i=0;i<m;i++)
{
scanf ("%d%d", &a[i][0],&a[i][1]);
}
if (m<3)
{
printf ("0\n");
return 0;
}
int sum=0;
for (i=0;i<m-2;i++)
{
for (j=i+1;j<m-1;j++)
{
for (int l=j+1;l<m;l++)
{
if ((a[i][0]==a[j][0]&&a[i][0]==a[l][0)) | | ((A[l][1]-a[j][1]) * (a[j][0]-a[i][0]) = = (A[l][0]-a[j][0]) * (a[j][1]-a[i][1]))) Continue
sum++;
}
}
}
printf ("%d\n", sum);
}
*/

/*e*/

/* Add a set of parentheses and the maximum ~~*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <bits/stdc++.h>
#include <string.h>

using namespace Std;

Char s[5005];
int n=0;
Long Long cal (const char *s,int l,int R)
{
Stack<long long> num;
Stack<char> Ope;
Ope.push (' (');
for (int i=l;i<=r;i++)
{
Char C=s[i];
if (i==r) c= ') ';
if (IsDigit (c))
{
Num.push (c ' 0 ');
}
Else
{
if (c== ' (')
{
Ope.push (' (');
Continue
}
while (!ope.empty () && ((c== ') ' &&ope.top ()! = ' (') | | (c!= ') ' &&ope.top () <=c&&ope.top ()! = ' (')))
{
Long long a=num.top ();
Num.pop ();
Long long b=num.top ();
Num.pop ();
if (ope.top () = = ' * ') Num.push (a*b);
else Num.push (a+b);
Ope.pop ();
}
if (c== ') ') Ope.pop ();
else Ope.push (c);
}
}
return Num.top ();
}

int p[5000],cnt;
Char sa[5005];
int main ()
{
s[0]= ' 1 ';//both before and after the addition of parentheses can be used to pass the sentence without looking at the end
s[1]= ' * ';
Gets (s+2);
N=strlen (s);
s[n++]= ' * ';
s[n++]= ' 1 ';
Long Long int ans=cal (S,0,N);
for (int i=0;i<n;i++)
{
if (s[i]== ' * ') p[cnt++]=i; Where the Mark has appeared *
}
for (int i=0;i<cnt;i++)
{
for (int j=i+1;j<cnt;j++)
{
int pos=0;
for (int k=0;k<n;k++)
{
if (K==p[j]) sa[pos++]= ');
SA[POS++]=S[K];
if (K==p[i]) sa[pos++]= ' (';
}
sa[pos]=0;
Ans=max (Ans,cal (Sa,0,pos));
}

}
printf ("%lld\n", ans);
return 0;
}
Nothing to say is four mixed operation but to be skilled ...


That's it. 2333333333



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Codeforces 552 for the first time to be able to do all out DIV2 shed tears of moving ....

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.