mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
第三届“图灵杯”趣味网络邀请赛 (初级)
This commit is contained in:
parent
42f16ec07f
commit
66dedd2b6f
44
XJOI/contest/21novice/A/A.cpp
Normal file
44
XJOI/contest/21novice/A/A.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n;
|
||||
string ans[15][10];
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
ans[1][1] = "+ +\n +\n+ +\n";
|
||||
ans[2][1] = "+ +\n + +\n +\n + +\n+ +\n";
|
||||
ans[3][1] = "+ +\n + +\n + +\n +\n + +\n + +\n+ +\n";
|
||||
ans[4][1] = "+ +\n + +\n + +\n + +\n +\n + +\n + +\n + +\n+ +\n";
|
||||
ans[5][1] = "+ +\n + +\n + +\n + +\n + +\n +\n + +\n + +\n + +\n + +\n+ +\n";
|
||||
ans[6][1] = "+ +\n + +\n + +\n + +\n + +\n + +\n +\n + +\n + +\n + +\n + +\n + +\n+ +\n";
|
||||
ans[7][1] = "+ +\n + +\n + +\n + +\n + +\n + +\n + +\n +\n + +\n + +\n + +\n + +\n + +\n + +\n+ +\n";
|
||||
ans[8][1] = "+ +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n+ +\n";
|
||||
ans[9][1] = "+ +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n+ +\n";
|
||||
ans[10][1] = "+ +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n+ +\n";
|
||||
ans[1][2] = "+ +\n +\n +\n";
|
||||
ans[2][2] = "+ +\n + +\n +\n +\n +\n";
|
||||
ans[3][2] = "+ +\n + +\n + +\n +\n +\n +\n +\n";
|
||||
ans[4][2] = "+ +\n + +\n + +\n + +\n +\n +\n +\n +\n +\n";
|
||||
ans[5][2] = "+ +\n + +\n + +\n + +\n + +\n +\n +\n +\n +\n +\n +\n";
|
||||
ans[6][2] = "+ +\n + +\n + +\n + +\n + +\n + +\n +\n +\n +\n +\n +\n +\n +\n";
|
||||
ans[7][2] = "+ +\n + +\n + +\n + +\n + +\n + +\n + +\n +\n +\n +\n +\n +\n +\n +\n +\n";
|
||||
ans[8][2] = "+ +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n";
|
||||
ans[9][2] = "+ +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n";
|
||||
ans[10][2] = "+ +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n + +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n +\n";
|
||||
ans[1][3] = "++ \n+ +\n++\n";
|
||||
ans[2][3] = "++++\n+ +\n+ +\n+ +\n++++\n";
|
||||
ans[3][3] = "++++++\n+ +\n+ +\n+ +\n+ +\n+ +\n++++++\n";
|
||||
ans[4][3] = "++++++++\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n++++++++\n";
|
||||
ans[5][3] = "++++++++++\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n++++++++++\n";
|
||||
ans[6][3] = "++++++++++++\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n++++++++++++\n";
|
||||
ans[7][3] = "++++++++++++++\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n++++++++++++++\n";
|
||||
ans[8][3] = "++++++++++++++++\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n++++++++++++++++\n";
|
||||
ans[9][3] = "++++++++++++++++++\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n++++++++++++++++++\n";
|
||||
ans[10][3] = "++++++++++++++++++++\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n+ +\n++++++++++++++++++++\n";
|
||||
cout << ans[n][1] << endl
|
||||
<< ans[n][2] << endl
|
||||
<< ans[n][3] << endl;
|
||||
return 0;
|
||||
}
|
24
XJOI/contest/21novice/B/B.cpp
Normal file
24
XJOI/contest/21novice/B/B.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, m, lx, ly, rx, ry;
|
||||
pair<int, int> point[1005];
|
||||
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
for (int i = 0; i < n; i++) {
|
||||
cin >> point[i].first >> point[i].second;
|
||||
}
|
||||
for (int i = 0; i < m; i++) {
|
||||
cin >> lx >> ly >> rx >> ry;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (lx <= point[i].first && point[i].first <= rx && ly <= point[i].second && point[i].second <= ry) {
|
||||
cout << "Yes" << endl;
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << "No" << endl;
|
||||
return 0;
|
||||
}
|
26
XJOI/contest/21novice/C/C.cpp
Normal file
26
XJOI/contest/21novice/C/C.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, p;
|
||||
string s;
|
||||
stack<pair<char, int>> st;
|
||||
|
||||
int main() {
|
||||
cin >> n >> p >> s;
|
||||
s = ' ' + s;
|
||||
for (int i = 1; i < s.size(); i++) {
|
||||
if (s[i] == '{') {
|
||||
st.push(make_pair(s[i], i));
|
||||
} else if (st.top().second == p) {
|
||||
cout << i << endl;
|
||||
exit(0);
|
||||
} else if (i == p) {
|
||||
cout << st.top().second << endl;
|
||||
exit(0);
|
||||
} else {
|
||||
st.pop();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
52
XJOI/contest/21novice/D/D.cpp
Normal file
52
XJOI/contest/21novice/D/D.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int t, a, cnt, prime[100005];
|
||||
bool flag, is_prime[1000005];
|
||||
|
||||
int eratosthenes(int n) {
|
||||
int p = 0;
|
||||
for (int i = 0; i <= n; i++) is_prime[i] = 1;
|
||||
is_prime[0] = is_prime[1] = 0;
|
||||
for (int i = 2; i <= n; i++) {
|
||||
if (is_prime[i]) {
|
||||
prime[p++] = i;
|
||||
if (1ll * i * i <= n) {
|
||||
for (int j = i * i; j <= n; j += i) {
|
||||
is_prime[j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
long long binpow(long long a, long long b, long long m) {
|
||||
a %= m;
|
||||
long long res = 1;
|
||||
while (b > 0) {
|
||||
if (b & 1) res = res * a % m;
|
||||
a = a * a % m;
|
||||
b >>= 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> t;
|
||||
cnt = eratosthenes(1000000);
|
||||
while (t--) {
|
||||
flag = false;
|
||||
cin >> a;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
if (binpow(a, prime[i], 10) % 10 == binpow(prime[i], a, 10) % 10) {
|
||||
cout << prime[i] << endl;
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) cout << -1 << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user