kakaの博客

你所热爱的,就是你的生活

0%

比赛链接:https://codeforces.ml/contest/1602

A. Two Subsequences

直接找到最小的字符输出,然后把剩下的也输出

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
const ll inf = 1e18;
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const double eps = 1e-8;
const int mod = 1e9 + 7;

#define fi first
#define se second
#define re register
#define lowbit (-x&x)

void solve() {
int T; cin >> T; while (T--) {
string s; cin >> s;
vector<int> vis(100+1);
int idx = 0;
for (int i = 1; i < s.size(); i++) {
if (s[i]< s[idx]) {
idx = i;
}
}
vis[idx] = 1;
cout << s[idx] << ' ';
for (int i = 0; i < s.size(); i++) {
if (!vis[i]) cout << s[i];
}
cout << endl;
}
}

signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef ACM_LOCAL
freopen("input", "r", stdin);
freopen("output", "w", stdout);
#endif

#ifdef ACM_LOCAL
auto start = clock();
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
#ifdef ACM_LOCAL
auto end = clock();
cerr << "Run Time: " << double(end - start) / CLOCKS_PER_SEC << "s" << endl;
#endif
return 0;
}

B. Divine Array

阅读全文 »

比赛链接:https://codeforces.ml/contest/1582

A. Luntik and Concerts

直接找规律,发现答案肯定只有01。

  1. 模上1,2,3的公倍数,然后暴力枚举
  2. (a+c)%2
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
const ll inf = 1e18;
const int N = 3e5 + 10;
const int M = 1e6 + 10;
const double eps = 1e-8;
const int mod = 1e9 + 7;

#define fi first
#define se second
#define re register
#define lowbit (-x&x)
#define endl '\n'

void solve() {
int T; cin >> T; while (T--) {
int a, b, c; cin >> a >> b >> c;
cout << (a+c)%2 << endl;
}
}

signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef ACM_LOCAL
freopen("input", "r", stdin);
freopen("output", "w", stdout);
#endif

#ifdef ACM_LOCAL
auto start = clock();
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
#ifdef ACM_LOCAL
auto end = clock();
cerr << "Run Time: " << double(end - start) / CLOCKS_PER_SEC << "s" << endl;
#endif
return 0;
}
阅读全文 »

比赛链接:点这里

A. Windblume Ode

题意:取一个集合的最大子集使得sum不为质数。

直接上手猜的结论,最少有n-1个数,然后暴力去判就行

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
29
30
31
32
33
34
35
36
bool is_prime(int x) {
if (x == 1) return true;
for (int i = 2; i * i <= x; i++) {
if (x % i == 0) return false;
}
return true;
}
int a[N];
void solve() {
int T; cin >> T; while (T--) {
int n; cin >> n;
int ans = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
ans += a[i];
}
if (!is_prime(ans)) {
cout << n << endl;
for (int i = 1; i <= n; i++) cout << i << ' ';
cout << endl;
} else {
cout << n - 1 << endl;
int f = 0;
for (int i = 1; i <= n; i++) {
if (!is_prime(ans-a[i])) {
f = i;
break;
}
}
for (int i = 1; i <= n; i++) {
if (i != f) cout << i << ' ';
}
cout << endl;
}
}
}
阅读全文 »

比赛链接点这里

A. Mike and palindrome

必须改变一个字母,使得字符串变成回文串。

直接暴力枚举每个字符然后判断就行。

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
const ll inf = 1e18;
const int N = 2e5 + 10;
const int M = 1e6 + 10;
const double eps = 1e-8;
const int mod = 998244353;

#define fi first
#define se second
#define re register
#define lowbit (-x&x)
bool check(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[s.size()-i-1] != s[i]) return false;
}
return true;
}
void solve() {
string s; cin >> s;
int f = 0;
for (int i = 0; i < s.size(); i++) {
char tmp = s[i];
for (int j = 0; j < 26; j++) {
s[i] = 'a' + j;
if (s[i] == tmp) continue;
if (check(s)) f = 1;
}
s[i] = tmp;
}
if (f) cout << "YES" << endl;
else cout << "NO" << endl;
}

signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef ACM_LOCAL
freopen("input", "r", stdin);
freopen("output", "w", stdout);
#endif

#ifdef ACM_LOCAL
auto start = clock();
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
#ifdef ACM_LOCAL
auto end = clock();
cerr << "Run Time: " << double(end - start) / CLOCKS_PER_SEC << "s" << endl;
#endif
return 0;
}
阅读全文 »