2016/04/02省选练习赛(1)



J - Java Beans   ZOJ 3714

Description

There are N little kids sitting in a circle, each of them are carrying some java beans in their hand. Their teacher want to selectM kids who seated inM consecutive seats and collect java beans from them.

The teacher knows the number of java beans each kids has, now she wants to know the maximum number of java beans she can get fromM consecutively seated kids. Can you help her?

Input

There are multiple test cases. The first line of input is an integer T indicating the number of test cases.

For each test case, the first line contains two integers N (1 ≤ N ≤ 200) andM (1 ≤MN). Here N and M are defined in above description. The second line of each test case containsN integersCi (1 ≤Ci ≤ 1000) indicating number of java beans theith kid have.

Output

For each test case, output the corresponding maximum java beans the teacher can collect.

Sample Input

2
5 2
7 3 1 3 9
6 6
13 28 12 10 20 75

Sample Output

16
158
手速题,我打的,还tmWA了一发,队友翻译说是从序列中选出m个,使其和最大,WA之后,发现根本不是这么回事,再次翻译后发现,n个数是一个圆,且取连续的m个数。
将序列再重复一遍,(样例1:7 3 1 3 9 7 3 1 3 9)从第一个数暴力求连续m个数的和,输出最大的。52Min2Y;
代码:
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int c[1000000];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        memset(c,0,sizeof(c));
        for(int i=0;i<a;i++)
        {
            cin>>c[i];
            c[i+a]=c[i];
        }
        int ans=-1;
        int j=0;
        for(int i=0;i<2*a;i++)
        {
            if(j==a)
            break;
            j++;
            int sum=0;
        for(int k=0;k<b;k++)
        {
            sum+=c[i+k];
        }
        if(sum>ans)
            ans=sum;
        sum=0;
        }
        cout<<ans<<endl;
    }
}
H - Hard to PlayZOJ 3712 

Description

MightyHorse is playing a music game called osu!.

2016/04/02省选练习赛(1)_第1张图片

After playing for several months, MightyHorse discovered the way of calculating score in osu!:

1. While playing osu!, player need to click some circles following the rhythm. Each time a player clicks, it will have three different points: 300, 100 and 50, deciding by how clicking timing fits the music.

2. Calculating the score is quite simple. Each time player clicks and gets P points, the total score will add P, which should be calculated according to following formula:

P = Point * (Combo * 2 + 1)

Here Point is the point the player gets (300, 100 or 50) and Combo is the number of consecutive circles the player gets points previously - That means if the player doesn't miss any circle and clicks the ith circle, Combo should be i - 1.

Recently MightyHorse meets a high-end osu! player. After watching his replay, MightyHorse finds that the game is very hard to play. But he is more interested in another problem: What's the maximum and minimum total score a player can get if he only knows the number of 300, 100 and 50 points the player gets in one play?

As the high-end player plays so well, we can assume that he won't miss any circle while playing osu!; Thus he can get at least 50 point for a circle.

Input

There are multiple test cases.

The first line of input is an integer T (1 ≤ T ≤ 100), indicating the number of test cases.

For each test case, there is only one line contains three integers: A (0 ≤ A ≤ 500) - the number of 300 point he gets, B (0 ≤ B ≤ 500) - the number of 100 point he gets and C (0 ≤ C ≤ 500) - the number of 50 point he gets.

Output

For each test case, output a line contains two integers, describing the minimum and maximum total score the player can get.

Sample Input

1
2 1 1 

Sample Output

2050 3950
我打的,翻译不是太准确,但大概意思还是有,类似于节奏大师的游戏,有300,100,50三中基础分,combo是你的连击数,题目规定你不会miss,求你能获得的min max分数,当combo越大时分数越高,所以max是先选低基础分,min是先选高基础分。68Min1Y;

F - FriendsZOJ 3710

Time Limit: 2000 MS Memory Limit: 65536 KB

64-bit integer IO format: %lld , %llu Java class name: Main

[Submit] [Status]

Description

Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends in several days. Currently, there are totally n people in the country, and m friendship among them. Assume that any new friendship is made only when they have sufficient friends in common mentioned above, you are to tell how many new friendship are made after a sufficiently long time.

Input

There are multiple test cases.

The first lien of the input contains an integer T (about 100) indicating the number of test cases. Then T cases follow. For each case, the first line contains three integers n, m, k (1 ≤ n ≤ 100, 0 ≤ m ≤ n×(n-1)/2, 0 ≤ k ≤ n, there will be no duplicated friendship) followed by m lines showing the current friendship. The ith friendship contains two integers ui, vi (0 ≤ ui, vi < n, ui ≠ vi) indicating there is friendship between person ui and vi.

Note: The edges in test data are generated randomly.

Output

For each case, print one line containing the answer.

Sample Input

3
4 4 2
0 1
0 2
1 3
2 3
5 5 2
0 1
1 2
2 3
3 4
4 0
5 6 2
0 1
1 2
2 3
3 4
4 0
2 0

Sample Output

2
0
4


    
    
    
    
    
    
    
    

    
    
    
    
     
     
     
     

队友写的,队友花了很长时间在写这道题,最后A了结果不错,但罚时。。。。从开始也许就不该先开这题。。85Min4Y;

题意:

有 n个人,m对朋友,当两个人的公共朋友》=k时,俩人可以成为新朋友,求这种新朋友的数量。

我不知道思路。。。。

代码:

#include<stdio.h> #include<string.h> int d[101][101]; int main() { int t; scanf("%d",&t); while(t--) { int i,j,k,a,b,c,xt,yt,flag,sum=0,fflag; scanf("%d%d%d",&a,&b,&c); memset(d,0,sizeof(d)); while(b--) { scanf("%d%d",&xt,&yt); d[xt][yt]=1; } do { fflag=0; for(i=0; i<a; i++) { for(j=i+1; j<a; j++) { flag=0; for(k=0; k<a; k++) { if(((d[i][k]==1)||(d[k][i]==1))&&((d[k][j]==1)||(d[j][k]==1)))flag++; } if((flag>=c)&&(d[i][j]!=1)&&(d[j][i]!=1)) { d[i][j]=1; fflag++; sum++; } } } }while(fflag!=0); printf("%d\n",sum); } return 0; }

B - Break Standard WeightZOJ 3706

Description

The balance was the first mass measuring instrument invented. In its traditional form, it consists of a pivoted horizontal lever of equal length arms, called the beam, with a weighing pan, also called scale, suspended from each arm (which is the origin of the originally plural term "scales" for a weighing instrument). The unknown mass is placed in one pan, and standard masses are added to this or the other pan until the beam is as close to equilibrium as possible. The standard weights used with balances are usually labeled in mass units, which are positive integers.

With some standard weights, we can measure several special masses object exactly, whose weight are also positive integers in mass units. For example, with two standard weights 1 and 5, we can measure the object with mass 1, 4, 5 or 6 exactly.

In the beginning of this problem, there are 2 standard weights, which masses are x and y. You have to choose a standard weight to break it into 2 parts, whose weights are also positive integers in mass units. We assume that there is no mass lost. For example, the origin standard weights are 4 and 9, if you break the second one into 4 and 5, you could measure 7 special masses, which are 1, 3, 4, 5, 8, 9, 13. While if you break the first one into 1 and 3, you could measure 13 special masses, which are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13! Your task is to find out the maximum number of possible special masses.

Input

There are multiple test cases. The first line of input is an integer T < 500 indicating the number of test cases. Each test case contains 2 integers x and y. 2 ≤ x, y ≤ 100

Output

For each test case, output the maximum number of possible special masses.

Sample Input

2
4 9
10 10

Sample Output

13
9

队友写的,他们在讨论这道题的时候,我在写模拟,所以完全不知道这道题是什么意思hahahah 196Min1Y;

代码:

#include<stdio.h>
int fu[3]= {1,0,-1};
int zong[27]= {};
int main()
{
    int t,i,j,k,sum,i1,i2,i3,temp,flag,mmax;
    scanf("%d",&t);
    while(t--)
    {
        int xt,yt;
        scanf("%d%d",&xt,&yt);
        mmax=0;
        for(i=1; i<=xt/2; i++)
        {
            j=0;
            for(i1=0; i1<3; i1++)
            {
                for(i2=0; i2<3; i2++)
                {
                    for(i3=0; i3<3; i3++)
                    {
                        temp=fu[i1]*i+fu[i2]*(xt-i)+fu[i3]*yt;
                        if(temp>0)
                        {
                            flag=0;
                            for(k=0; k<27; k++)
                            {
                                if(zong[k]==temp)
                                {
                                    flag=1;
                                }
                            }
                            if(flag!=1)
                            {
                                zong[j]=temp;
                                j++;
                            }
                        }
                    }
                }
            }
            if(mmax<j)mmax=j;
            memset(zong,0,27*sizeof(int));
        }
        for(i=1; i<=yt/2; i++)
        {
            j=0;
            for(i1=0; i1<3; i1++)
            {
                for(i2=0; i2<3; i2++)
                {
                    for(i3=0; i3<3; i3++)
                    {
                        temp=fu[i1]*i+fu[i2]*(yt-i)+fu[i3]*xt;
                        if(temp>0)
                        {
                            flag=0;
                            for(k=0; k<27; k++)
                            {
                                if(zong[k]==temp)
                                {
                                    flag=1;
                                }
                            }
                            if(flag!=1)
                            {
                                zong[j]=temp;
                                j++;
                            }
                        }
                    }
                }
            }
            if(mmax<j)mmax=j;
            memset(zong,0,27*sizeof(int));
        }
        printf("%d\n",mmax);
    }
}



最后的时间我在写一个非常长的模拟,队友在看别人A出来的题,可是模拟出了一些状况,磕磕巴巴的模拟出它说的东西,但是RE了 改了很多遍都不行,莫名其妙

题目:A - ApplicationsZOJ 3705 大家可以去尝试下


   
   
   
   
 
  
 
 



你可能感兴趣的:(2016/04/02省选练习赛(1))