2015 Xiangtan University Programming Competition (INTERNET)

Source: Internet
Author: User

Some time ago, due to the problem of campus network, has been not open csdn, coupled with the slack of the former, I have not written a blog for a long time, but for the upcoming provincial games and Blue

Bridge Cup, I decided to be reformed and make progress.

Topic Link: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/38

Chinese Paladin Topic Link: http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1225

Water problem, do not explain.

#include <iostream>
#include <cstdio>
using namespace std;
int main ()
{
    int T;
    scanf ("%d", &t);
    while (t--)
    {
        int i,n,l,ans=0,x,tmp=100;
        scanf ("%d%d", &n,&l);
        for (i=0;i<n;i++)
        {
            scanf ("%d", &x);
            if (l>=x)
                ans+=10/(l-x+1);
            if (ans>=tmp)
            {
                tmp+=100;
                l++
            }
        }
        printf ("%d%d\n", L,ans);
    }
    return 0;
}


Folding

Topic Link:

http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1226

Water problem, do not explain.

#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main ()
{
    int T;
    scanf ("%d", &t);
    while (t--)
    {
        int i,l,a=0,b=0;
        String str;
        cin>>str;
        L=str.size ();
        if (l==1)
            cout<<str<<endl;
        else if (l%2==0)
        {for
            (i=0;i<l/2;i++)
                a=a*10+str[i]-' 0 ';
            for (i=l-1;i>=l/2;i--)
                b=b*10+str[i]-' 0 ';
            printf ("%d\n", a+b);
        }
        else
        {for
            (i=0;i<=l/2;i++)
                a=a*10+str[i]-' 0 ';
            for (i=l-1;i>l/2;i--)
                b=b*10+str[i]-' 0 ';
            printf ("%d\n", a+b*10);
        }
    return 0;
} <span style= "FONT-SIZE:24PX;" >
</span>

Digit

Topic Link:

http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1227

At that time, the language understanding ability is too poor, do not know what the meaning of digital, and then explained by the teammate, just know is 123456789101112 ... These numbers have been lined up

Go, and then let you ask for the number of nth, I immediately, cry dizzy. In fact, it is not difficult to solve this problem, first simulate the number of digits, find out which digits, and then the solution can be.

#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace

Std

typedef long Long LL;
    int main () {int t,t=9;;
    ll I,NUM[10],MAXN[10];
    num[1]=9;
    Maxn[1]=1;
        for (i=2;i<10;i++) {t*=10;
        NUM[I]=I*T+NUM[I-1];
    maxn[i]=maxn[i-1]*10;
    } scanf ("%d", &t);
        while (t--) {ll n;
        scanf ("%lld", &n);
            if (n<10) {printf ("%lld\n", N);
        Continue
        ll Pos=1;
                for (i=1;i<10;i++) if (num[i]>=n) {pos=i;
                N-=NUM[I-1];
            Break
        int flag=0;
        if (n%pos==0) flag=-1;
        Long Long Ans=maxn[pos]+n/pos+flag;
                for (i=0;i<pos;i++) {if (pos-i)%pos==n%pos) {printf ("%lld\n", ans%10);
            Break
     } ans/=10;   } return 0;
 }

the smallest number

Topic Link:

http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1228

have done similar problems before, but did not say only adjacent exchange. But this problem is not very difficult. Start with a different array, from small to large, then from the first in order to traverse (first can not be 0) and the small number of exchanges, why not say the smallest number, because the topic gives the exchange of the number of steps, so you find in the limited number of steps and then Exchange, if the number of steps are sufficient, then the next operation, The procedure repeats the first step.

#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace
Std
    int main () {int T;
    scanf ("%d", &t);
        while (t--) {char str[1010],tmp[1010];
        int vis[1010];
        int i,j,k,l,p,t1;
        memset (Vis) (vis,0,sizeof);
        scanf ("%s%d", str,&k);
        L=strlen (str);
        strcpy (TMP,STR);
        Sort (tmp,tmp+l);
                for (i=0;i<l&&k;i++) {for (j=0;j<l;j++) {int flag=1; if (vis[j]| |
                Tmp[j]>=str[i]) continue;
                if (!i&&tmp[j]== ' 0 ') continue;
                        for (p=i+1;p<l;p++) {if (Str[p]==tmp[j]) {
                        if (k<p-i) flag=0;
                            else {k-= (p-i); For(t1=p;t1>i;t1--) Swap (str[t1],str[t1-1]);
                        Vis[j]=1;
                    } break;
            } if (flag) break;
            }//cout<<str<<endl;
        cout<<k<<endl;
    printf ("%s\n", str);
return 0;
 }

annoying, different or

5. To tell you the truth, I don't know how to do this problem yet. Put on someone else's blog first, and then update it later.

Http://www.cnblogs.com/zhengguiping--9876/p/4461329.html
6.Curious Maze is a problem of egg ache, these days busy save game, later update.

http://202.197.224.59/OnlineJudge2/index.php/Contest/read_problem/cid/38/pid/1230

Life Achievement Topic Link: http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1231

DP water problem. First use the DP to find the maximum number, and then simulate the process to find all the way.

 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm

> Using namespace std;
int a[510][510];
int dp[510][510];

int num[510][510];
    int main () {int n;
        while (scanf ("%d", &n)!=eof) {int i,j;
        Memset (Dp,0,sizeof (DP));
        memset (num,0,sizeof (num));
                for (i=1;i<=n;i++) {for (j=1;j<=n;j++) {scanf ("%d", &a[i][j]);
            Dp[i][j]=max (Dp[i][j-1],dp[i-1][j]) +a[i][j];
        }} num[1][1]=1; for (i=1;i<=n;i++) {for (j=1;j<=n;j++) {if a[i][j]==dp[i][j]-dp[i][j
                -1]) num[i][j]+=num[i][j-1];
                if (A[i][j]==dp[i][j]-dp[i-1][j]) num[i][j]+=num[i-1][j];
            num[i][j]%=123456;
    } printf ("%d\n", Num[n][n]);
return 0; }

8. Bracket Matching topic link: http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1232

A simple use of stack, thought, my code in the comments have been very detailed not to say more.

#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <stack

> #include <map> #include <algorithm> using namespace std;

struct Node {int Index,x,y,r[4];//index represents its ordinal number, X represents its property, y indicates its sequence or preface, r[] in turn represents parentheses, brackets, braces}no[100010];
    int main () {char str[100010];
    int mm,x;
    Map<char,int> m;
    Stack<node> s;
    m[' (']=1;m[' [']=2;m[' {']=3;
        m[') ']=4;m['] ']=5;m['} ']=6;//attributes with a map bracket while (scanf ("%s", str+1)!=eof) {memset (no));
        int i;
            for (i=1;str[i];i++) {no[i].index=i;
            No[i].x=m[str[i]];
            if (m[str[i]]<=3) S.push (No[i]);
                else {node p,t;
                P=s.top ();
                S.pop ();    No[i].y=p.index;
                Record its pre-ordered p.y=i;
                    if (S.size ()) {t=s.top ();
   S.pop ();                 T.R[1]+=P.R[1];
                    T.R[2]+=P.R[2];
                    T.R[3]+=P.R[3];
                    t.r[p.x]++;
                S.push (t);  } no[p.index]=p;
        Assignment before} scanf ("%d", &mm);
            while (mm--) {scanf ("%d", &x);
            Int J;   J=min (X,NO[X].Y);
        Because the given X is likely to be a subsequent sequence, it is necessary to judge printf ("%d%d%d%d\n", no[x].y,no[j].r[1],no[j].r[2],no[j].r[3]);
    printf ("\ n");
return 0;
 }




Related Article

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.