Skip to content

Commit 5ffeeff

Browse files
author
ksh-code
committed
y
1 parent 8da171c commit 5ffeeff

37 files changed

+1333
-1
lines changed

10859.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
void solve(){
6+
string str; cin >> str;
7+
8+
ll r = stoll(str);
9+
for (ll i = 2; i * i <= r; i++) {
10+
if (r % i == 0) {
11+
cout << "no";
12+
return;
13+
}
14+
}
15+
if (r == 1) {
16+
cout << "no";
17+
return;
18+
}
19+
20+
r = 0;
21+
for (int i = 0; i < str.size(); i++) {
22+
if (str[i] == '3' || str[i] == '4' || str[i] == '7') {
23+
cout << "no";
24+
return;
25+
}
26+
r *= 10;
27+
char c = str[str.size()-1-i];
28+
int t = c - '0';
29+
switch (t) {
30+
case 6:
31+
t = 9;
32+
break;
33+
case 9:
34+
t = 6;
35+
break;
36+
}
37+
r+=t;
38+
}
39+
40+
for (ll i = 2; i * i <= r; i++) {
41+
if (r % i == 0 || r == 1) {
42+
cout << "no";
43+
return;
44+
}
45+
}
46+
if (r == 1) {
47+
cout << "no";
48+
return;
49+
}
50+
cout << "yes";
51+
}
52+
53+
int main()
54+
{
55+
cin.tie(0)->sync_with_stdio(false);
56+
solve();
57+
return 0;
58+
}

12865.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ int main()
3838

3939
cout << result;
4040
return 0;
41-
}
41+
}

1315.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
struct Node {
6+
int a,b,c;
7+
};
8+
9+
void solve(){
10+
int N;cin >>N;
11+
12+
Node arr[N]; for (int i = 0; i < N; i++) cin >> arr[i].a >> arr[i].b >> arr[i].c;
13+
14+
int points[1001][1001]; // STR, INT
15+
for (int i = 1; i <= 1000; i++) {
16+
for (int j = 1; j <= 1000; j++) {
17+
points[i][j] = -1;
18+
}
19+
}
20+
21+
bool cleared[1001][1001]; memset(cleared, 0, sizeof(cleared));
22+
23+
cleared[1][0] = cleared[0][1] = points[1][0] = points[0][1] = 1;
24+
25+
int result = 0;
26+
for (int STR = 1; STR <= 1000; STR++) {
27+
for (int INT = 1; INT <= 1000; INT++) {
28+
points[STR][INT] = 2-(STR+INT);
29+
30+
int clear = 0;
31+
32+
for (int i = 0; i < N; i++) {
33+
auto [a,b,c] = arr[i];
34+
if (a <= STR || b <= INT) {
35+
points[STR][INT] += c;
36+
clear++;
37+
}
38+
}
39+
40+
if (
41+
(cleared[STR - 1][INT] && points[STR - 1][INT] > 0) ||
42+
(cleared[STR][INT - 1] && points[STR][INT - 1] > 0)
43+
) {
44+
cleared[STR][INT] = true;
45+
result = max(result, clear);
46+
}
47+
}
48+
}
49+
50+
cout << result;
51+
}
52+
53+
int main()
54+
{
55+
cin.tie(0)->sync_with_stdio(false);
56+
solve();
57+
return 0;
58+
}

13702.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
const int MAX = 1e4;
6+
7+
void solve(){
8+
int N, K; cin >> N >> K;
9+
ll arr[N]; for (int i = 0; i < N; i++) cin >> arr[i];
10+
ll l = 0, r = *max_element(arr, arr+N) + 1;
11+
12+
ll result = 0;
13+
while (l + 1 < r) {
14+
ll m = (l + r) / 2;
15+
16+
ll cnt = 0;
17+
for (int i = 0; i < N; i++) {
18+
cnt += arr[i] / m;
19+
}
20+
21+
if (cnt >= K) {
22+
result = max(result, m);
23+
l = m;
24+
} else r = m;
25+
}
26+
cout << result;
27+
}
28+
29+
int main()
30+
{
31+
cin.tie(0)->sync_with_stdio(false);
32+
solve();
33+
return 0;
34+
}

13703.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
void solve(){
6+
}
7+
8+
int main()
9+
{
10+
cin.tie(0)->sync_with_stdio(false);
11+
solve();
12+
return 0;
13+
}

14256.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
void solve(){
6+
ll N, M; cin >> N >> M;
7+
ll result = 0;
8+
set<ll> s;
9+
for (ll i = 1; i*i <= N*M; i++) {
10+
s.insert(i*i);
11+
}
12+
for (ll i = 1; i <= N; i++) {
13+
set<ll> check;
14+
for (ll j = 1; j * j <= M; j++) {
15+
for (ll k = i*j; k <= N * M; k += i * j) {
16+
ll c = k / (i*j);
17+
if (c > M) break;
18+
check.insert(c);
19+
if (s.count(k)) result++;
20+
}
21+
}
22+
}
23+
cout << result;
24+
}
25+
26+
int main()
27+
{
28+
cin.tie(0)->sync_with_stdio(false);
29+
solve();
30+
return 0;
31+
}

14267.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
const int MAX = 1e5;
6+
int tree[MAX*4];
7+
int lazy[MAX*4];
8+
9+
vector<vector<int>> edges(MAX+1);
10+
11+
int node_count;
12+
int start[MAX+1];
13+
int last[MAX+1];
14+
void dfs(int x, int parent) {
15+
start[x] = ++node_count;
16+
for (auto node : edges[x]) {
17+
dfs(node, x);
18+
}
19+
last[x] = node_count;
20+
}
21+
22+
int N, M;
23+
24+
void propagation(int s, int e, int node) {
25+
if (!lazy[node]) return;
26+
tree[node] += lazy[node];
27+
if (s != e) for (int i = node*2; i <= node*2+1; i++) lazy[i] += lazy[node];
28+
lazy[node] = 0;
29+
}
30+
31+
void update(int s, int e, int node, int l, int r, int diff) {
32+
if (s > r || e < l) return;
33+
if (s >= l && e <= r) {
34+
lazy[node] += diff;
35+
return;
36+
}
37+
38+
int m = (s+e)/2;
39+
update(s, m, node*2, l, r, diff);
40+
update(m+1, e, node*2+1, l, r, diff);
41+
}
42+
43+
int query(int s, int e, int node, int l, int r) {
44+
if (s > r || e < l) return 0;
45+
propagation(s, e, node);
46+
if (s >= l && e <= r) return tree[node];
47+
int m = (s+e)/2;
48+
return query(s, m, node*2, l, r) + query(m+1, e, node*2+1, l , r);
49+
}
50+
51+
void solve(){
52+
cin >> N >> M;
53+
for (int i = 1; i <= N; i++) {
54+
int parent; cin >> parent;
55+
if (i > 1) edges[parent].push_back(i);
56+
}
57+
58+
dfs(1, -1);
59+
60+
while (M--) {
61+
int a,b;
62+
cin >> a >> b;
63+
update(1, N, 1, start[a], last[a], b);
64+
}
65+
for (int i = 1; i <= N; i++) {
66+
cout << query(1, N, 1, start[i], start[i]);
67+
cout << ' ';
68+
}
69+
}
70+
71+
int main()
72+
{
73+
cin.tie(0)->sync_with_stdio(false);
74+
solve();
75+
return 0;
76+
}

15966.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
void solve(){
6+
int N; cin >> N;
7+
int dp[1000000+1]; memset(dp, 0, sizeof(dp));
8+
9+
int result = 1;
10+
for (int i = 0; i < N; i++) {
11+
int a; cin >> a;
12+
dp[a] = max(dp[a], dp[a-1]+1);
13+
result = max(dp[a], result);
14+
}
15+
cout << result;
16+
}
17+
18+
int main()
19+
{
20+
cin.tie(0)->sync_with_stdio(false);
21+
solve();
22+
return 0;
23+
}

16396.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
5+
void solve(){
6+
int N; cin >> N;
7+
8+
bool lines[10001]; memset(lines, 0, sizeof(lines));
9+
10+
int result = 0;
11+
for (int i = 0; i < N; i++) {
12+
int x,y;cin>>x>>y;
13+
for (;x < y; x++) {
14+
if (lines[x]) continue;
15+
lines[x] = true;
16+
result++;
17+
}
18+
}
19+
cout << result;
20+
}
21+
22+
int main()
23+
{
24+
cin.tie(0)->sync_with_stdio(false);
25+
solve();
26+
return 0;
27+
}

0 commit comments

Comments
 (0)