Codeforces Round #467 (Div. 2) 937ABC

10603 단어 Codeforces
첫 번째 문제: A. Olympiad time limit per test 1 second memory limit per test 256 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 are to determine the set of participants to be awarded with diplomas with respect 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 is awarded, all participants with score not less than his score should also be awarded. 

Determine the number of ways to choose a subset of participants that will 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 that at 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 are three ways to choose a subset in sample case one.
Only participants with 3 points will get diplomas.
Participants with 2 or 3 points will get diplomas.
Everyone will get a diploma! 

The only option in sample case two is to award everyone.
Note that in sample case three participants with zero scores cannot get anything. 제목: 제목: 올림픽에는 세 가지 시상 기준이 있는데 하나는 0의 성적을 주지 않는 것이고, 하나는 0보다 높은 성적을 주는 것이며, 하나는 0이 아닌 성적을 주는 사람에게 시상하는 것이다. 총 몇 가지 시상 방안이 있느냐고 묻는다.
문제풀이: 0이 아닌 다른 숫자의 개수를 판단하는 것은 set로 판단할 수 있다(또는 너무 느린 요리인가)
#include
using namespace std;
int a[500];
int main()
{
    int n;

    while(cin >> n)
    {  set<int> s;
        for(int i =0;i < n;i ++)
        {
            cin >>a[i];
            s.insert(a[i]);
        }
        int aa = *s.begin();
        if(aa!=0)
        {
            cout << s.size() << endl;
        }else
        {
            cout << s.size() - 1 << endl;
        }

    }
    return 0;
}

두 번째 문제:
B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 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) are occupied by tiny vile grasshoppers which you’re at war with. These grasshoppers are known for their awesome jumping skills: the grasshopper at branch x can jump to branches .
Keeping this in mind, you wisely decided to choose such a branch that 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 is to find the highest branch that cannot be reached by any of the grasshoppers or report that it’s impossible. Input
The only line contains two integers p and y (2 ≤ p ≤ y ≤ 109). Output
Output the number of the highest suitable branch. If there are 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 is initially settled by another grasshopper. Therefore the answer is 5.
It immediately follows that there are no valid branches in second sample case.
제목: p, y 두 개 주기;p에서 y까지의 구간에서 2에서 p 사이의 배수가 아닌 최대 수풀이를 구한다. 즉 소수에 해당하지만 최대 수는 y보다 작은 소수보다 반드시 크다.코드는 다음과 같습니다.
#include
using namespace std;
int main()
{
    int p,y;
    while(~scanf("%d %d",&p,&y))
    {
        for(int i = y; i > p; i --)
        {
            int s = min(p,(int)(sqrt(i)));
            bool flag = true;
            for(int j = 2; j <= s; j ++)
            {
                if(i % j== 0)
                {
                    flag =false;
                    break;
                }
            }
            if(flag)
            {
                printf("%d
"
, i); return 0; } } printf("-1
"
); } return 0; }

세 번째 문제: C. Save Energy!time limit per test 1 second memory limit per test 256 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 k minutes after 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 that the chicken needs t minutes to be cooked on the stove, if it is turned on, and 2t minutes, if it is turned off. You need to find out, how much time will Julia have to cook the chicken, if it is considered that the chicken is cooked evenly, with constant speed when the stove is turned on and at a constant speed when it is 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 is x and the answer of the jury is y. The checker program will 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 will be cooked for 3 minutes on the turned on stove, after this it will be cooked for . Then the chicken will be cooked for one minute on a turned off stove, it will be cooked for . Thus, after four minutes the chicken will be cooked for . Before the fifth minute Julia will turn on the stove and after 2.5 minutes the chicken will be ready .
In the second example, when the stove is turned off, Julia will immediately turn it on, so the stove will always be turned on and the chicken will be cooked in 20 minutes.
문제풀이: 한 전자레인지에서 닭 한 마리를 요리할 때 t시간이 필요합니다. 그렇지 않으면 2t시간이 필요합니다. 한 번에 불을 붙이면 k시간이 지속됩니다. d시간이 지나면 전자레인지가 열리는지 확인합니다. 이 닭이 삶은 총 시간을 물어보세요.
/// 2*t   
#include
using namespace std;
typedef long long ll;
int main()
{
    ll k,d,t;///t             ,2*t          
    while(~scanf("%lld %lld %lld",&k,&d,&t))
    {
        ll xx = k / d;
        if(k % d != 0) xx ++;///          
        xx *= d;///             

        ll xxx = 2*k+(xx - k);///xx-k           2*k     

                 ll tt =  2*t/ xxx;///         

        double ans =1.0*tt*xx;

        ll ttt = t * 2 % xxx;///    

        if(2*k >= ttt)
        {
            ans += 1.0*ttt/2;
        }
        else
        {
            ans += k;
            ans += (ttt - 2 * k);
        }
        printf("%.10f
"
,ans); } return 0; }

좋은 웹페이지 즐겨찾기