Top

河南农业大学训练赛标程


河南农业大学测试赛标程

博主CSDN

A.最大最小值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e9 + 10;
const int mod = 1e9 + 7;
int main(){
int t;
scanf("%d", &t);
while (t--){
int n;
scanf("%d", &n);
ll a, min_ = maxn, max_ = -maxn;
for (int i = 0; i < n; i++){
scanf("%lld", &a);
if (a>max_)max_ = a;
if (a < min_)min_ = a;
}
printf("%lld %lld\n", max_, min_);
}
return 0;
}

B.找众数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e9 + 10;
const int mod = 1e9 + 7;
int num[120];
int main(){
int t;
scanf("%d", &t);
while (t--){
int n,a;
memset(num, 0, sizeof(num));
scanf("%d", &n);
for (int i = 0; i < n; i++){
scanf("%d", &a);
num[a]++;
}
int b = 0;
a = 0;
for (int i = 0; i <= 100; i++){
if (num[i] >= a)b = i,a=num[i];
}
printf("%d\n", b);

}
return 0;
}

C.买!买!买!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 10;
const int mod = 1e9 + 7;
int a[] = { 15, 25};
int dp[maxn];
int main(){
int t;
scanf("%d", &t);
while (t--){
int n;
scanf("%d", &n);
memset(dp, 0, sizeof(dp));
dp[0] = 1;
for (int i = 10; i <= n * 10; i+=5){
for (int j = 0; j < 2; j++){
if (i >= a[j]){
dp[i] += dp[i - a[j]];
}
}
}
printf("%d\n", dp[n * 10]);
}
return 0;
}


未经允许不得转载: Anoyer's Blog » 河南农业大学训练赛标程