第五届华中区程序设计邀请赛暨武汉大学第十四届校赛 网络预选赛

Problem 1611 - Null
Description

  Null.

Input
Null
Output
Output “Null” in a line.
Sample Input
Null
Sample Output
Null
Hint
Source


#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    string s;
    cin>>s;
    cout<<s<<endl;
    return 0;
}

Problem 1606 - Funny Sheep
Description

There are N+1 rows and M+1 columns fence with N*M grids on the grassland. Each grid has a sheep. In order to let the sheep together, we need to dismantle the fence. Every time you can remove a row or a column of fences. What’s the least number of times to reach the goal? 

Input
There are multiple test cases.
The first line of each case contains two integers N and M. (1≤N,M≤1000)
Output
For each case, output the answer in a line.
Sample Input
1 2
2 2
Sample Output

2
Hint
Source


#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int min(int a,int b)
{
    if(a<b)
        return a;
    else
        return b;
}
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        int ans=min(a,b);
        if(a==1&&b==1)
            ans = 0;
        printf("%d\n",ans);
    }
    return 0;
}


Problem 1604 - Play Apple
Description

There are N apples. Two people take turns to either: 
1. Divide the apple into two piles with different numbers.
2. The other people selects a pile of apples as the beginning of the next turn.
If someone can not meet the requirements, he is lost. Will the first one win the game if both use the best strategy?

Input
There are multiple test cases.
The first line of each case contains a integer N. ( 1 <= N <= 1000000000 )
Output
If the first person will win, output “Yes”. Otherwise, output “No”.
Sample Input
2
3
4
Sample Output
No
Yes
No
Hint
Source


#include <iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;

typedef long long LL;
const int MOD=1000000007;


int main(){

  int N;

  while(scanf("%d",&N)!=EOF){
    if(N==1||N==2||N==4)
    {
        printf("No\n");
        continue;
    }
    if(N==3)
    {
        printf("Yes\n");
        continue;
    }
    if(N%3==1)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }

  }


  return 0;

}

Problem 1603 - Minimum Sum
Description

There are n numbers A[1] , A[2] .... A[n], you can select m numbers of it A[B[1]] , A[B[2]] ... A[B[m]]  ( 1 <= B[1] < B[2] .... B[m] <= n ) such that Sum as small as possible.

Sum is sum of abs( A[B[i]]-A[B[j]] ) when 1 <= i < j <= m.

Input
There are multiple test cases.
First line of each case contains two integers n and m.( 1 <= m <= n <= 100000 )
Next line contains n integers A[1] , A[2] .... A[n].( 0 <= A[i] <= 100000 )
It's guaranteed that the sum of n is not larger than 1000000.
Output
For each test case, output minimum Sum in a line.
Sample Input
4 2
5 1 7 10
5 3
1 8 6 3 10
Sample Output
2
8
Hint
Source

#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=100000+10;
typedef long long ll;
ll a[maxn];
ll he;
int cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        he=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%lld",&a[i]);
        }
        sort(a+1,a+n+1,cmp);
        ll s=0;
        for(int i=1; i<=m; i++)
        {
            s+=(m-i)*a[i];
            he+=a[i];
        }
        for(int i=1; i<=m; i++)
        {
            s-=(i-1)*a[i];
        }
        ll ans=s;
        for(int i=m+1; i<=n; i++)
        {
        //    ll k=s-(m-1)*a[i-m]+2*(he-a[i-m])-(m-1)*a[i];
                ll k=s-(m-1)*a[i]+2*(he-a[i-m])-(m-1)*a[i-m];
            ans=min(ans,k);
            s=k;
            he=he-a[i-m]+a[i];
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Problem 1609 - Han Move
Description
Cyy and Fzz are Han Move lovers. One day, they gather together to run. They choose a circular track whose length is L m. Cyy’s speed is A m/s and Fzz’s speed is B m/s. They may choose the direction separately, i.e. they may start with the same direction or different direction. As they’re crazy, they’ll run infinitely. Gatevin, their friend, wonders the possibility of their distance is less than D m. The distance is defined as the distance on the track. The possibility is defined as the ratio between the sum of time satisfying the condition and the total time.
Input
The input file consists of multiple test cases ( around 1000000 ).
Each test case consists of 5 integers L, A, B, D, Dir in a line. The meanings of L, A, B, D are as described above. Dir means whether they are in the same direction. Dir = 1 means they are in the same direction, while Dir = 0 means they are in the opposite direction. ( 1 <= L, A, B, D <= 32768, 0 <= Dir <= 1 )
Output
For each test case, output the possibility rounded to 6 demical places in a line.
Sample Input
1200 200 400 300 0
1200 200 400 300 1
Sample Output
0.500000
0.500000
Hint

 Please pay attention to the speed of I/O.

Source

#include <iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;

typedef long long LL;
const int MOD=1000000007;

int main()
{

    int L,A,B,D,dir;
    double ans;
    while(scanf("%d%d%d%d%d",&L,&A,&B,&D,&dir)!=EOF)
    {

        if(dir == 1)
        {
            if(A == B)
                ans = 1;
            else
            {
                if(2*D/L>=1)
                    ans = 1;
                else
                    ans=2*D*1.0/L;
            }
        }
        else if(dir == 0)
        {
            if(2*D/L>=1)
                ans = 1;
            else
            {
                ans=2*D*1.0/L;
            }
        }
        printf("%.6lf\n",ans);

    }

}



你可能感兴趣的:(第五届华中区程序设计邀请赛暨武汉大学第十四届校赛 网络预选赛)