A - 青年歌手大奖赛_评委会打分

 



青年歌手大奖赛_评委会打分

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 104819    Accepted Submission(s): 51776


Problem Description

青年歌手大奖赛中,评委会给参赛选手打分。选手得分规则为去掉一个最高分和一个最低分,然后计算平均得分,请编程输出某选手的得分。

 


Input

输入数据有多组,每组占一行,每行的第一个数是n(2<n<=100),表示评委的人数,然后是n个评委的打分。

 


Output

对于每组输入数据,输出选手的得分,结果保留2位小数,每组输出占一行。

 


Sample Input


3 99 98 974 100 99 98 97

 

Sample Output


98.0098.50

 


Author

lcy


注意一下数据类型为浮点型就好了

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e3+6;
double a[maxn];
int main()
{
int n;
while(~scanf("%d",&n))
{
for(int i=0;i<n;i++)
scanf("%lf",a+i);
sort(a,a+n);
double sum=0;
for(int i=1;i<n-1;i++)
sum+=a[i];
printf("%.2f\n",sum/(n-2));
}
return 0;
}

B - 偶数求和

 




偶数求和

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 106685    Accepted Submission(s): 44357


Problem Description


有一个长度为n(n<=100)的数列,该数列定义为从2开始的递增有序偶数,现在要求你按照顺序每m个数求出一个平均值,如果最后不足m个,则以实际数量求平均值。编程输出该平均值序列。


 


Input


输入数据有多组,每组占一行,包含两个正整数n和m,n和m的含义如上所述。


 


Output


对于每组输入数据,输出一个平均值序列,每组输出占一行。


 


Sample Input





3 24 2



 


Sample Output





3 63 7



 


细心一点儿就好了

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+6;
int a[120];

int main()
{
for(int i=0;i<102;i++)
a[i]=i*2;
int n,m,sum;
while(~scanf("%d %d",&n,&m))
{

for(int i=0;i<n/m;i++)
{
sum=0;
for(int j=i*m+1;j<=m*(i+1);j++)
{
sum+=a[j];
}
if(i) printf(" ");
printf("%d",sum/m);
}
if(n%m)
{
sum=0;
int x=n-(n/m)*m;
for(int i=m*(n/m)+1;i<=n;i++)
sum+=a[i];
printf(" %d",sum/x);
}
printf("\n");
}
return 0;
}

​C - 三角形​

三角形

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 108913    Accepted Submission(s): 35707


Problem Description

给定三条边,请你判断一下能不能组成一个三角形。

 


Input

输入数据第一行包含一个数M,接下有M行,每行一个实例,包含三个正数A,B,C。其中A,B,C <1000;

 


Output

对于每个测试实例,如果三条边长A,B,C能组成三角形的话,输出YES,否则NO。

 


Sample Input


21 2 32 2 2

 

Sample Output


NOYES

 


Author

linle


水题,注意一下数据范围是实数

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e3+6;

int main()
{
double a,b,c;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf %lf %lf",&a,&b,&c);
double x=max(a,max(b,c));
if(x<(a+b+c-x)) printf("YES\n");
else printf("NO\n");
}
return 0;
}

​D - Text Volume​

A. Text Volume


time limit per test

1 second



memory limit per test

256 megabytes



input

standard input



output

standard output


You are given a text of single-space separated words, consisting of small and capital Latin letters.

Volume of the word is number of capital letters in the word. Volume of the text is maximum volume

Calculate the volume

Input


The first line contains one integer number n (1 ≤ n ≤ 200) — length of the text.

The second line contains text of single-space separated words s1, s2, ..., si, consisting only of small and capital Latin letters.

Output


Print one integer number — volume

Examples


Copy


7 NonZERO


Copy


5


Copy


24 this is zero answer text


Copy


0


Copy


24 Harbour Space University


Copy


1

给你一行短文, 由单个空格分开的一些单词组成,仅包含大写字母和小写字母.




单词的Volume代表: 这个单词中大写字母的个数




短文的Volume等于该短文包含的所有单词的Volume的最大值




你的目标是计算给定短文的Volume.




Input


第一行包含一个整数n (1 ≤ n ≤ 200) — 代表短文的长度.




第二行包含一行短文,由单个空格分开的一些单词s1, s2, ..., si组成,由大写字母和小写字母组成.




Output


输出一个整数 — 该短文的Volume.


#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e3+6;
char s[maxn];
int main()
{
int n;
scanf("%d",&n);
getchar();//吸收回车符
gets(s);
int v=0;//记录单词的Volume
int ans=0;//记录短文的Volume
for(int i=0;i<n;i++)
{
if(s[i]==' ')
{
ans=max(ans,v);
v=0;
}
if(s[i]>='A'&&s[i]<='Z') v++;
}
ans=max(ans,v);
printf("%d\n",ans);
return 0;
}

​E - Digit Sums​

Digit Sums


Time limit : 2sec / Memory limit

Score : 200


Problem Statement

Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101)=1+0+1=2.

Given an integer N, determine if S(N) divides N.


Constraints

  • 1≤N≤109



Input

Input is given from Standard Input in the following format:


N


Output

If S(N) divides N, print ​​Yes​​; if it does not, print ​​No​​.



Sample Input 1


Copy


12


Sample Output 1


Copy


Yes


In this input, N=12. As S(12)=1+2=3, S(N) divides N.



Sample Input 2


Copy


101


Sample Output 2


Copy


No


As S(101)=1+0+1=2, S(N) does not divide N.



Sample Input 3


Copy


999999999


Sample Output 3


Copy


Yes

令S(N) : 十进制表示法中,N 的各位数字相加之和. 例如, S(101) = 1 + 0 + 1 = 2.




给你一个整数 N, 判断 S(N) 能否整除 N .




Constraints


1 <= N <= 10^9




Input


输入仅一行,一个整数N




Output


如果 S(N) 能整除 N, 输出 Yes; 否则, 输出 No.


根据题意直接做就行了

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e3+6;


int s(int n)
{
int ans=0;
while(n)
{
ans+=n%10;
n/=10;
}
return ans;
}

int main()
{
int n;
while(~scanf("%d",&n))
{
if(n%s(n)) printf("No\n");
else printf("Yes\n");
}
return 0;
}

​F - Generous Kefa​

Generous Kefa


time limit per test

2 seconds



memory limit per test

256 megabytes



input

standard input



output

standard output


One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all baloons to his friends. Help Kefa to find out, can he give out all his baloons, such that no one of his friens will be upset — print «YES», if he can, and «NO», otherwise. Note, that Kefa's friend will not upset, if he doesn't get baloons at all.

Input


The first line contains two integers n and k (1 ≤ n, k ≤ 100) — the number of baloons and friends.

Next line contains string s

Output


Answer to the task — «YES» or «NO» in a single line.

You can choose the case (lower or upper) for each letter arbitrary.

Examples


Copy


4 2 aabb


Copy


YES


Copy


6 3 aacaab


Copy


NO

Note


In the first sample Kefa can give 1-st and 3-rd baloon to the first friend, and 2-nd and 4-th to the second.

In the second sample Kefa needs to give to all his friends baloons of color a, but one baloon will stay, thats why answer is «NO».


别想太多......

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+6;
int a[100];
bool cmp(int x,int y)
{
return x>y;
}
int main()
{
int n,m;
while(~scanf("%d %d",&n,&m))
{
memset(a,0,sizeof(a));
char s[maxn];
scanf("%s",s);
for(int i=0;i<strlen(s);i++)
a[s[i]-'A']++;
sort(a,a+100,cmp);
if(a[0]>m) printf("NO\n");
else printf("YES\n");
}
return 0;
}

G - Godsend

 



 Godsend


time limit per test

2 seconds



memory limit per test

256 megabytes



input

standard input



output

standard output


Leha somehow found an array consisting of n

Input


First line of input data contains single integer n (1 ≤ n ≤ 106) — length of the array.

Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).

Output


Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes).

Examples


Copy


4 1 3 2 3


Copy


First


Copy


2 2 2


Copy


Second

Note


In first sample first player remove whole array in one move and win.

In second sample first player can't make a move and lose.

2018年HPUACM暑期集训招新赛_i++

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e3+6;


int main()
{
int n;
while(~scanf("%d",&n))
{
ll sum=0;
int k=0;
for(int i=0;i<n;i++)
{
int x;
scanf("%d",&x);
sum+=x;
if(x&1) k=1;
}
if(sum&1) printf("First\n");
else if(k) printf("First\n");
else printf("Second\n");
}
return 0;
}

H - Sorting Railway Cars

 Sorting Railway Cars


time limit per test

2 seconds



memory limit per test

256 megabytes



input

standard input



output

standard output


An infinitely long railway has a train consisting of n cars, numbered from 1 to n

Input


The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train.

The second line contains n integers pi (1 ≤ pi ≤ npi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.

Output


Print a single integer — the minimum number of actions needed to sort the railway cars.

Examples


Copy


5 4 1 2 5 3


Copy


2


Copy


4 4 1 3 2


Copy


2

Note


In the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.


这一题是要找最长的连续递增子序列,自己想了好久没想出来,竞赛结束后看了网上大佬们写的代码,发现原来是这样做的,


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=1e5+6;
typedef long long ll;
int a[maxn];
int main()
{
int n;
while(~scanf("%d",&n))
{
int k;
int ans=0;
memset(a,0,sizeof(a));
for(int i=0;i<n;i++)
{
scanf("%d",&k);
if(a[k-1])
{
a[k]=a[k-1]+1;
}
else
a[k]=1;
ans=max(ans,a[k]);
}
printf("%d\n",n-ans);
}
return 0;
}