Beijing University October 2018 Program Design Competition part of the puzzle (A,C,E,H)

Source: Internet
Author: User



Directory


    • Beijing University October 2018 Program Design Competition part of the puzzle (A,C,E,H)
      • Events related to competitions
        • Contest Links
        • Contest topics
        • Summarize
Beijing University October 2018 Program Design Competition part (A,C,E,H) Contest event related contest link


Although I guess it was better when I sent this essay, I still put the link up.



A game


http://116.196.97.99/contest.php
If the link is not set, you can copy the URL here.
I made the title of the contest C. Zzh topic description of water problem


Zzh is the new generation of the northern ACM community, and every day with countless big guys from all over the world to communicate. However, Zzh has limited time for daily water groups. Zzh wants to communicate with as many big-brother as possible. He expressed the strength of each big man with a number ω, and each day with the highest sum of Omega of the big guys to communicate. But Zzh is busy with the water group, so he gave you the problem. After the event, Zzh will give you 2147483647%1 gold as a reward.


Input


Single set of data



The first line of two integers n,m, representing the time of today's Zzh Water group (in minutes) and the number of big guys who want to communicate with Zzh today (<=2000).



After M line, there are two numbers, which represent the time spent (<n) and the Big Guy's Omega (<1000).


Output


Today the sum of the values of the Omega of the big guy who communicates with Zzh.


Sample input
70 3
71 100
69 3
1 2
Sample output
5


This question is a very common knapsack problem, then I will not do, I used their previous code, I review, I reflect!


#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int V,n;
    cin>>V>>n;
    int v[2100],p[2100],dp[2100];
    memset(v,0,sizeof(v));
    memset(p,0,sizeof(p));
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
        cin>>v[i]>>p[i];
    for(int i=1;i<=n;i++)
        for(int j=V;j>=v[i];j--)
            dp[j]=max(dp[j-v[i]]+p[i],dp[j]);
    cout<<dp[V];
}


Knapsack problem will be, will not write, probably. There's nothing to say, next.


A. Intellectual Grand Prix title description




Input


Only one row, with an integer N, representing the number of layers of the large triangle (n<=45000)


Output


There are two lines,
The first line has only one number, which indicates the number of small triangles;
The second line also has only one number, which indicates the number of energy bars.


Sample input
8
Sample output
64108


Listen to the opposite of me said a very good to do, but the data is too big.



Emmmmm, OK, no problem, BigInteger go!



Probably the idea is the 1th row 1 triangle, 2nd row 2+1, 3rd line 3+2 ...



Then the energy bar is the 1th row 3, the 2nd row 6, the 3rd line 9 root ...



Very simple one problem, the difficulty is in the data is too big, but, I BigInteger feared who??


import java.math.BigDecimal;
import java.util.Scanner;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        BigInteger x1 = BigInteger.ZERO;
        BigInteger x2 = BigInteger.ZERO;
        BigInteger x3 = BigInteger.ZERO;
        BigInteger y1 = BigInteger.ZERO;
        BigInteger a1 = BigInteger.ONE;
        BigInteger b1 = BigInteger.ONE;
        BigInteger a2 = BigInteger.ZERO;
        b1=b1.add(a1);
        b1=b1.add(a1);
        for(int i=0;i<n;i++) {
            x1=x1.add(a1);
            x2=x2.add(a2);
            a1=a1.add(BigInteger.ONE);
            a2=a2.add(BigInteger.ONE);
            y1=y1.add(b1);
            b1=b1.add(BigInteger.ONE);
            b1=b1.add(BigInteger.ONE);
            b1=b1.add(BigInteger.ONE);
        }
        x3=x1.add(x2);
        System.out.println(x3); 
        System.out.println(y1); 
    }

}


Ability to switch between C + + and Java I'm awesome 233333



Next, H, it feels pretty simple.


H. Description of the series of questions


The story is not made up, M brother!



Given an n-length sequence A, there are now three operations:
1, 1 p x: Change a[p] to X
2, 2 L R: a[l] to a[r] The difference between the maximum value and the minimum value
3, 3 L R: a[l] to A[r] and
Now give you some operation, please find the corresponding value.


Input


The first line enters a number T to represent the number of data groups (1<=T<=10)
Next T Group data, the first behavior of each group of data two integers n, m (1<=n,m<=1e5), respectively, represents the length of a and operands, the next row n integer represents a[1] to an, followed by M line, each line of the input format as given in the operation of the
(1<=p,l,r<=n,0<=x<=1000)


Output


For each set of data
For each operation 2 or 3, output an integer representing the result


Sample input
2
4 4
1 2 3 4
2 1 2
1 2 7
2 1 2
3 1 4
5 4
2 7 6 3 8
2 1 3
1 3 1
2 1 5
3 3 3
Sample output
1
6
15
5
7
1


It's really simple, isn't it just some array manipulation? How to do so few people ...



The only thing to be aware of is that the array in question starts at 1.


#include <iostream>
using namespace std;
int suan(int a[],int l,int r){
    int m1,m2;
    m1=a[l];
    m2=a[l];
    for(int i=l+1;i<=r;i++){
        m1=m1>a[i]?m1:a[i];
        m2=m2<a[i]?m2:a[i];
    }
    return m1-m2;
}
int add(int a[],int l,int r){
    int s=0;
    for(int i=l;i<=r;i++){
        s+=a[i];
    }
    return s;
}
int main()
{
    int t,n,m,x,p,y,l,r;
    cin>>t;
    while(t--){
        cin>>n>>m;
        int a[n+1];
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        while(m--){
            cin>>x;
            switch(x){
                case 1:cin>>p>>y;
                        a[p]=y;
                        break;
                case 2:cin>>l>>r;
                        cout<<suan(a,l,r)<<endl;
                        break;
                case 3:cin>>l>>r;
                        cout<<add(a,l,r)<<endl;
                        break;
            }
        }
    }
}


Please do not care about my random function name!



And then this time I found my platoon 12??! Never so high, confidence is greatly increased!!!






Come on!



See E seems to do a lot of people, I also try it!


E. Cloud computing Topic description


The ACM society has n cloud servers, each server has a lifetime, and the first server can also use RI days. There are now m tasks that need to be deployed to a cloud server to run, and the J task needs to run TJ days. The J task can be deployed on the I server when and only if Tj <=ri, and each server can only run a single task for the duration of its lifetime. Even if TK+TJ <=ri, you will not be able to deploy the K and J tasks together to the first server, otherwise this problem will lose its role in the check-in question (I laughed when I saw the characters of the sign-in question). In order to take full advantage of the cloud server, you now need to calculate how many tasks can be deployed. And you as a north of the hope of ACM, this problem needs to be solved by you.


Input


Single set of data
The first row of two integers represents N and M
The second row n integers represent r1,r2,...,rn
The third row of M integers represents T1,T2,...,TM
1<= N,M,TJ, Ri <=100000


Output


Output An integer representing the maximum number of tasks that can be deployed to the cloud server


Sample input

Sample output
3


Since it is a check-in question, haha, then there is nothing to say, come on, I am not afraid of you!


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n,m,s=0;
    cin>>n>>m;
    int a[n],b[m];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    int j=0;
    for(int i=0;i<m;){
        if(b[i]<=a[j]){
            i++;
            j++;
            s++;
        }
        else{
            j++;
        }
        if(j==n){
            break;
        }
    }
    cout<<s;
}


Well, it's easy, just sort it out, and then judge if it's enough.



And then!!! 8th!!!



But unfortunately, I stopped 4, and then did not make out, the rankings also dropped to more than 50, but also very strong Ah! Long time not to do the problem unexpectedly can also break through the last results.


I didn't make it. B. Description of number of primes




Input


A total of two lines:
The first Action n L, the middle is separated by a space. (1<=n<=100, 1<=l<=7)
The second behavior is a number of n 0~9, separated by a space in the middle.


Output


Only one row, with all the prime numbers that satisfy the condition, is separated by commas, guaranteeing that there is at least a prime number.


Sample input
10 38 9 1 0 2 3 5 4 7 6
Sample output
547


I feel the code is no problem, but just can't live. I won't let it go.


D. Description of the building block title


I'm tired of making up stories, M-brother!
There are n blocks, the height of the first building blocks is a[i], and there are several blocks in front of each block that are shorter than it.


Input


Multiple sets of inputs, each set consists of two lines, the first line of N, the second line of n number, the height of n bricks a[i]
(1<=n<=100000) (1<=a[i]<=1000000000)


Output


Each set of data output n number, number I is the number of bricks in front of the first building blocks than he


Sample input
51 2 3 4 5
Sample output
0 1 2 3 4


This problem is loved by the timeout, and finally did not find a good algorithm.


Don't understand, don't want to see F Luo Dalao's password title description


As we all know, Luo Dalao is very powerful. One day, Luo Dalao invented a password to encrypt the document (it can be thought that the document is a string s of length n).
Luo Dalao to s[l]...s[r] encryption, first to reverse the interval s[l]...sr, then k= (r-l+1)/2 (rounding down), and then reverse the interval s[l]...s[l+k-1] and s[l+k]...s[r], and so on, Until the interval length is 1. (Encrypt entire document equivalent to encryption interval s[1]...s[n])
One day you found a Dalao encrypted document, and now you want to find the location before the character is encrypted.


Input


The first line inputs the integer t (0<t<=1000), which represents the number of data groups, the next T line, two integers per line n and P (1<=p<=n<=1e18), respectively, indicating the document length and the location of the query.


Output


Output t lines, one integer per line, representing the original position of the characters at p position in each set of data


Sample input
44 14 24 34 4
Sample output
3412
G. Luo Dalao's small film title description


Luo Dalao is very strong, so there will be a lot of people ask him some questions, and he has l minutes a day dedicated to answering questions. Because there are a lot of people to consult, so to find Luo Dalao ask questions, need to book.
So, Luo Dalao know that every day there will be N people to ask questions, the first arrival of the person in the first AI minutes to arrive, Luo Dalao answer questions to use Ti minutes (Luo dalao astute arrangements to ensure ai+ti<=ti+1 and an+tn<=l), However, Luo Dalao want to find free time to watch a small film, Luo Dalao see every small film to see the tail, period can not be interrupted, each small film of the time is M, Luo Dalao want to know how much he can see at most of the small film, now please help him calculate.


Input


Single Group
First row 3 integers: n,l and M (0<=n<=1e5,1<=l<=1e9,1<=m<=l)
Next n lines, two integers per line ai and Ti (0<=ai<=l-1,1<=ti<=l)


Output


Output An integer that shows how many small movies Dalao can see


Sample input
2 11 30 11 1
Sample output
3
I.leo's Simple Law problem description


Leo likes to eat barbecue, and only eat three kinds, mutton kebabs, vegetables, ham sausage, she ate barbecue before like to put a long string of barbecue, and there are special placing rules, wrong she this meal will not eat.
The rules are: 1. For a continuous three grilled skewers, no three skewers are the same.
2. For the continuous three grilled skewers, if there are three kinds of grilled skewers, green vegetables can not be placed in the middle (eat meat midway between eating is very self-closing)
3. is still for the continuous three grilled skewers, the first and third strings are vegetables, the middle can not be mutton or ham sausage (she meant to diet to lose weight)
Now there are three kinds of grilled skewers have countless roots, she would like to put a grilled string of length n, please find out the number of programs (because the results may be very large, so just give answer modulo 1000000007)


Input


The first line has a number T (t<100), which indicates that there is a T group of data
Next T line, one number per line N (1≤n≤1010)


Output


For each set of data, the output is assumed to be the number of packages with a length of n baked skewers


Sample input
42346
Sample output
92046244
Problem J.leo Simple Series Topic description


Leo has two numbers, and their lengths are N.
At the very beginning, the a sequence is the 0,b sequence is the number of n randomly populated by Leo (the number is 1-n, to ensure that the B-series is an arrangement of 1-n)
Now Leo can do both of these things.
\1. Add L R means she gives a sequence from a[l],a[l+1],..., A[r], plus a


    1. Query L R indicates that she wants to know the sum of all items when l<= i <=r a[i]/b[i] (rounded down)
      Of course, Leo in mathematics this piece is not very skilled, last monthly exam mathematics only 110 points, so I would like to ask you to help her complete these operations
Input


Multiple sets of data
For each set of data, the first row has 2 digit n,q, which represents the length and operand of a and B. 1<= N,q < =100000
The second line has n digits, indicating the initial state of the sequence B
Next Q line, one operation per line, specific operation format as given in the topic
1<= L <= R <= N


Output


For each query operation, the output line represents the result of the summation.


Sample input
6 106 1 4 3 2 5query 1 4add 2 2query 3 6add 1 6add 3 4query 2 5query 1 6add 2 4query 1 4query 3 5
Sample output
002241
Summarize


I really can only do a simple question.



Competition website



Beijing University October 2018 Program Design Competition part of the puzzle (A,C,E,H)


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.