You are on page 1of 7

#include <bits/stdc++.

h>
#define FOR(i,a,b) for(int i = a; i <= b; i++)
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
freopen("sd.inp", "r", stdin);
freopen("sd.out", "w", stdout);
int bai;
cin >> bai;
if(bai == 1) {
int a, b, c;
cin >> a >> b >> c;
int fmax = max({a,b,c});
if(fmax == a) cout << max(b,c);
else if(fmax == b) cout << max(a,c);
else cout << max(a,b);
}
if(bai == 2) {
int n;
cin >> n;
int A[n + 1];
int sum = 0;
int min_v = INT_MAX;
int max_v = INT_MIN;

int cnt_cs = 0;
FOR(i,1,n) {
cin >> A[i];
sum = sum + A[i];
max_v = max(max_v, A[i]);
min_v = min(min_v, A[i]);
int q = A[i];
while(q > 0) {
cnt_cs++;
q = q / 10;
}
}
float tb = (float) sum / n;
cout << fixed << setprecision(2) << tb <<
endl;
cout << cnt_cs << endl;
cout << min_v << " " << max_v;

FOR(i,1,n-1)
FOR(j,i+1,n)
if(A[i] > A[j])
swap(A[i], A[j]);
int k;
cin >> k;
cout << A[n - k + 1] << endl;
min_v = min_v + 3;
max_v = max(max_v, min_v);
cout << max_v << endl;
}
if(bai == 3) {
int n, m;
cin >> n >> m;
int A[n+1][m+1];
int fmax = INT_MIN, smax = INT_MIN, tmax =
INT_MIN;
FOR(i,1,n)
FOR(j,1,m) {
cin >> A[i][j];
fmax = max(fmax, A[i][j]);
}
FOR(i,1,n)
FOR(j,1,m)
if(A[i][j] > smax && A[i][j] < fmax)
smax = A[i][j];
FOR(i,1,n)
FOR(j,1,m)
if(A[i][j] < smax)
tmax = max(tmax, A[i][j]);
cout << tmax << endl;
FOR(i,1,n)
FOR(j,1,m)
if(i % 2 == 1 && j % 2 == 1)
A[i][j] = A[i][j] + 1;
FOR(i,1,n) {
FOR(j,1,m)
cout << A[i][j] << " ";
cout << endl;
}
FOR(j,1,m)
swap(A[1][j], A[2][j]);

int tong = 0;

FOR(i,1,n)
tong = tong + A[i][1] + A[i][2];
int cntl = 0, cntd = 0, cnta = 0;
FOR(i,1,n)
FOR(j, 1, m) {
if(i % 2 == 1) cntl++;
if(i < 0) cnta++;
else cntd++;
}
cout << cntl << " " << cntd << " " << cnta <<
endl;
}
if(bai == 4) {
//
}
if(bai == 5) {
int n;
cin >> n;
int F[n+1];
F[1] = 1;
F[2] = 1;
/**
7
1 1
for(3->7)
F[i] = F[i-1] + F[i-2];
F[3] = F[3-1] + F[3-2] = 2;
F[4] = F[4-1] + F[4-2] = 2 + 1 = 3;
F5 = 2 + 3 = 5
F6 = 5 + 3 = 8
F7 = 8 + 5 = 13
*/
FOR(i,3,n) F[i] = F[i-1] + F[i-2];
cout << F[n];
}
if(bai == 6) {
int n;
cin >> n;
int sum1 = 0;
float sum2 = 0;
for (int i = 1; i <= n; i++){
sum1 = sum1 + i * (i + 1) * (i + 2);
sum2 = sum2 + (float) i / ((i + 1) * (i +
2));
}
cout << sum1 << " " << sum2 << endl;
int k;
int n = 2;
cin >> k;
int sum = 0;
while (sum + n * (n * 2) < k){
sum = sum + n * (n * 2);
n++;
}
cout << n << endl;
return 0;
}
return 0;
}

You might also like