您的位置:首页 > 其它

Codeforces Round #467 (Div. 2) 937ABC

2018-02-26 12:20 197 查看
第一题:

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的都颁奖,一个是给成绩大于等于非零的数的人颁奖,问你共有多少种颁奖的方案。

题解:判断非零的不相同的数字个数,即可用set来判断(还是太菜速度太慢)

#include<bits/stdc++.h>
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<bits/stdc++.h>
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\n", i);
return 0;
}
}
printf("-1\n");
}
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<bits/stdc++.h>
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\n",ans);
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: