总91行代码集
Bing_laoqi114 · · 个人记录
T1 15行
#include<bits/stdc++.h>
using namespace std;
long long n, m, a[1234567], k, x, ans;
int main() {
cin >> n;
for(int i = 0; i < n; i++) {
cin >> x;
a[x]=1;
}
for(int i = 0; i <2345; i++)if(!a[i]) {
cout << i << endl;
return 0;
}
return 0;
}
T2 15行
#include<bits/stdc++.h>
using namespace std;
long long n, m, a[1234567], k, x, ans1, b[1234567], ans2;
int main() {
cin >> n;
for(int i = 0; i < n; i++)cin >> a[i];
for(int i = 0; i < n; i++)cin >> b[i];
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++) {
if(i == j && a[i] == b[j])ans1++;
if(i != j && a[i] == b[j])ans2++;
}
cout << ans1 << endl << ans2;
return 0;
}
T3 17行
#include<bits/stdc++.h>
using namespace std;
long long n, k, a[1234567], b[1234567],dp[1234567][2];
int main() {
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) cin >> b[i];
dp[1][0] = 1;
dp[1][1] = 1;
for(int i = 2; i <= n; i++) {
if((dp[i - 1][0] && abs(a[i - 1] - a[i]) <= k) || (dp[i - 1][1] && abs(b[i - 1] - a[i]) <= k)) dp[i][0] = 1;
if((dp[i - 1][1] && abs(b[i - 1] - b[i]) <= k) || (dp[i - 1][0] && abs(a[i - 1] - b[i]) <= k))dp[i][1] = 1;
}
if(dp[n][0] || dp[n][1]) cout << "Yes";
else cout << "No";
return 0;
}
T4 30行
#include<bits/stdc++.h>
using namespace std;
struct kkk {
int x, y;
char d;
} a[1234567];
bool cmp( kkk a, kkk b) {
if (a.y != b.y) return a.y < b.y;
return a.x < b.x;
}
long long n, m;
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y;
for (int i = 0; i < n; i++) cin >> a[i].d;
sort(a, a + n, cmp);
for (int i = 1; i <= n; i++) {
if (i == n || a[i].y != a[m].y) {
bool z = 0;
for (int j = m; j < i; j++) if (a[j].d == 'R') z = 1;
else if (a[j].d == 'L' && z) {
cout << "Yes" << endl;
return 0;
}
m = i;
}
}
cout << "No" << endl;
return 0;
}
T5 14行
#include<bits/stdc++.h>
using namespace std;
long long n, m, a[1234567], k, x, ans1, b[1234567], ans2, c[1234567];
int main() {
cin >> n >> m;
for(int i = n; i >= 0; i--)cin >> a[i];
for(int i = n + m; i >= 0; i--)cin >> c[i];
for(int i = 0; i <= m; i++) {
b[i] = c[i] / a[0];
for(int j = 1; j <= n; j++)c[i + j] -= b[i] * a[j];
}
for(int i = m; i >= 0; i--)cout << b[i] << " ";
return 0;
}