Codeforces Round #467 (Div. 2) a,b,c,d

Source: Internet
Author: User
Tags bool constant time limit
A. Olympiad time limit per test 1 second memory limit per test megabytes input standard input output standard output

The recent All-berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.

As the head of the programming committee, you is to determine the set of participants to is awarded with diplomas with RE SPECT to the following criteria:at least one participant should get a diploma. None of those with score equal to zero should get awarded. When someone was awarded, all participants with score not less than he score should also be awarded.

Determine the number of ways to choose a subset of participants that would receive the diplomas. Input

The first line contains a single integer n (1≤n≤100)-the number of participants.

The next line contains a sequence of n integers a1, a2, ..., an (0≤ai≤600)-participants ' scores.

It's guaranteed in least one participant has Non-zero score. Output

Print a single integer-the desired number of ways. Examples input Copy

4
1 3) 3 2
Output
3
Input Copy
3
1 1 1
Output
1
Input Copy
4
42 0) 0 42
Output
1
Note

There is three ways to choose a subset in sample case one. Only participants with 3 points would get diplomas. Participants with 2 or 3 points would get diplomas. Everyone would get a diploma!

The only option in award everyone.

Note that in the sample case three participants with zero scores cannot get anything.

Test instructions: Give a list of numbers that do not include 0 of the number of distinct numbers in this string.

Puzzle: Post-order violence once again

Code

#include <cstdio>
#include <algorithm>
#define MAX

using namespace std;

int A[max];

int main ()
{
    int n;
    while (scanf ("%d", &n)! = EOF)
    {
        for (int i = 0; i < n; i++)
            scanf ("%d", &a[i]);
        Sort (A, a + N);

        int count = 0;
        int flag = 0;
        for (int i = 0; i < n; i++)
        {
            if (A[i] > flag)
            {
                count++;
                flag = A[i];
            }
        }
        printf ("%d\n", count);
    }
    return 0;
}

B. Vile Grasshoppers time limit per test 1 second memory limit per test megabytes input standard input output standard Output

The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.

The pine ' s trunk includes several branches, located one above another and numbered from 2 to Y. Some of them (more precise, from 2 to P) is occupied by tiny vile grasshoppers which your ' re at the war with. These grasshoppers is known for their awesome jumping skills:the grasshopper at branch X can jump to branches.

Keeping this on mind, you wisely decided to choose such a branch so none of the grasshoppers could interrupt you. At the same time you wanna settle as high as possible since the view from up there is simply breathtaking.

In other words, your goal are to find the highest branch that cannot being reached by an any of the grasshoppers or report that I T ' s impossible. Input

The only line contains the integers p and y (2≤p≤y≤109). Output

Output the number of the highest suitable branch. If there is none, print-1 instead. Examples input Copy

3 6
Output
5
Input Copy
3 4
Output
-1
Note

In the first sample case grasshopper from branch 2 reaches branches 2, 4 and 6 while branch 3 are initially settled by Anot Her grasshopper. Therefore the answer is 5.

It immediately follows that there is no valid branches in second the sample case.
Test instructions: Grasshopper in the 2,3,...,p position, they can jump to 2*x,3*x ... Position, but not more than Y, required to find a position smaller than Y, the grasshopper is the largest position not to jump

The main reason: because to find the largest position, so directly from the Y violence to p, and then determine whether the position meets the conditions, the position of the judgment for the prime number of the judgment

Code

#include <cstdio>

int p, y;

BOOL judge (int x)
{for
    (int i = 2; I <= p && i * I <= x i++)
    {
        if (x% i = = 0) return false;< c6/>}
    return true;

int main ()
{while
    (scanf ("%d%d", &p, &y)! = EOF)
    {
        bool flag = true;
        int i;
        for (i = y; i > P; i--)
        {
            if (judge (i))
            {
                flag = false;
                break;
            }
        }
        if (!flag) printf ("%d\n", I);
        else printf (" -1\n");
    }
    return 0;
}

C. Save energy! Time limit per test 1 second memory limit per test megabytes input standard input output standard output

Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after kminutes over turning on.

During cooking, Julia goes to the kitchen every D minutes and turns on the stove if it is turned off. While the cooker is turned off, it stays warm. The stove switches on and off instantly.

It is known so the chicken needs T minutes to being cooked on the stove, if it was turned on, and 2t minutes, if it is Turne D off. You need to find out, how much time would Julia has to cook the chicken, if it's considered that the chicken is cooked EV Enly, with constant speed when the stove was turned on and at a constant speed when it was turned off. Input

The single line contains three integers k, D and T (1≤k, D, t≤1018). Output

Print a single number, the total time of cooking in minutes. The relative or absolute error must not exceed 10-9.

Namely, let's assume that your answer are x and the answer of the jury is Y. The checker program would consider your answer correct if. Examples input Copy

3 2 6
Output
6.5
Input Copy
4 2 20
Output
20.0
Note

In the first example, the chicken is cooked for 3 minutes on the turned on stove, after this it'll be cooked for

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.