A
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define mst(a, b) memset(a, b, sizeof a)
const int qq = 2e5 + 10;
const int MOD = 1e9 + 7;
int n, m, k;
int num[qq];
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
scanf("%d", num + i);
}
if(num[1] % 2 == 0 || num[n] % 2 == 0 || n % 2 == 0) {
puts("No");
return 0;
}
puts("Yes");
return 0;
}
B
题意:给出n个点,问是否存在两条不相交平行线使得所有点都落在这两条线上,每条平行线上至少要存在一个点
思路:分情况枚举,两个点在一个集合或者一个点自成一个集合
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define mst(a, b) memset(a, b, sizeof a)
const int qq = 2e3 + 10;
const int MOD = 1e9 + 7;
int n, m, k;
LL x[qq], y[qq];
int main() {
int n; scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
scanf("%lld", &y[i]);
x[i] = i;
}
LL x1, y1, x2, y2;
x1 = x[1], y1 = y[1];
bool flag = false;
for(int i = 2; i <= n; ++i) {
int f = 0;
LL a = (y[i] - y1), b = (x[i] - x1);
LL c, d;
bool Q = true;
for(int j = 2; j <= n; ++j) {
if(j == i) continue;
LL tmpy = y[j] - y1, tmpx = x[j] - x1;
if(a * tmpx == b * tmpy) continue;
if(f == 0) {
f++;
x2 = x[j], y2 = y[j];
} else if(f == 1) {
f++;
c = y[j] - y2, d = x[j] - x2;
} else {
LL tx = x[j] - x2, ty = y[j] - y2;
if(c * tx == d * ty) continue;
else Q = false;
}
}
if(f == 0) {
Q = false;
}else if(f == 1) {
LL tx = x2 - x1, ty = y2 - y1;
if(a * tx == b * ty) Q = false;
} else if(f == 2) {
if(a * d != b * c) Q = false;
}
if(Q) flag = true;
}
// printf("%d\n", flag);
bool f = true;
LL a = y[3] - y[2], b = x[3] - x[2];
for(int i = 4; i <= n; ++i) {
LL ty = y[i] - y[2], tx = x[i] - x[2];
if(a * tx != b * ty) f = false;
}
LL ty = y[1] - y[2], tx = x[1] - x[2];
if(a * tx == b * ty) f = false;
if(f) flag = true;
if(flag) puts("Yes");
else puts("No");
return 0;
}
C
题意:YY一下
思路:可以发现每一个字母 假设有n个字母a则字母a对整体的贡献是 1 + 2 + 3 + ... + n - 1, 所以直接暴力算即可
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define mst(a, b) memset(a, b, sizeof a)
const int qq = 2e3 + 10;
const int MOD = 1e9 + 7;
int n, m, k;
int main() {
cin >> k;
if(k == 0) {
puts("a");
return 0;
}
string ans;
for(int i = 0, j; i < 26 && k > 0; ++i) {
ans += (i + 'a');
for(j = 1; k - j >= 0; ++j) {
k = k - j;
ans += (i + 'a');
}
}
cout << ans << endl;
return 0;
}