题目链接
补题挖坑
A
码风淳朴勿喷呜呜,找位数关系,总位数大的就大,相等的凑到前面两个数相等然后继续比
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
ll t, n;
int main()
{
cin >> t;
while (t--)
{
ll a, b, p1, p2;
cin >> a >> p1 >> b >> p2;
ll x1 = a, x2 = b;
ll a_len = 0, b_len = 0;
while (a > 0)
{
a /= 10;
a_len++;
}
while (b > 0)
{
b /= 10;
b_len++;
}
// cout<<"dasdas" << a_len << ' ' << b_len << endl;
if (p1 + a_len > p2 + b_len)
cout << '>' << endl;
else if (p1 + a_len < p2 + b_len)
cout << '<' << endl;
else
{
ll cnt = a_len - b_len;
if (cnt > 0)
x2 *= (ll)pow(10, cnt);
else if (cnt < 0)
x1 *= (ll)pow(10, -cnt);
if (x1 > x2)
cout << '>' << endl;
else if (x1 < x2)
cout << '<' << endl;
else
cout << '=' << endl;
}
}
return 0;
}
B
找不到的话就每个数%第一小的数,输出 n 2 \frac{n}{2} 2n项就行了
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll t, n;
int main()
{
cin >> t;
while (t--)
{
cin >> n;
vector<ll> a(n);
for (auto &i : a)
cin >> i;
// unordered_map<int, bool> b;
sort(a.begin(), a.end());
int cnt = 0;
for (int i = n - 1; i >= 0; i--)
{
cout << a[i] << ' ' << a[0] << endl;
cnt++;
if (cnt >= n / 2)
break;
}
}
return 0;
}
C
二分答案,算是模板题目,不啦不啦
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
ll n, a, b, t, h;
int main()
{
cin >> t;
while (t--)
{
cin >> n >> h;
vector<ll> a(n);
for (int i = 0; i < n; ++i)
cin >> a[i];
ll l = 1, r = h;
while (l < r)
{
ll mid = l + r >> 1;
int flag = 0;
ll ans = 0;
for (int i = 1; i < n; ++i)
{
ans += min(mid, a[i] - a[i - 1]);
}
ans += mid;
if (ans < h)
l = mid + 1;
else
r = mid;
}
cout << l << endl;
}
return 0;
}
E
写了一半wa3不知道错哪了看到现在,唉,大哥们可以帮忙看看,我要是会了的话就补上了(虽然很小概率补)
我的想法就是从L开始bfs搜索
如果临点的
f
r
e
e
值
≤
1
free值\leq 1
free值≤1就变+
,free就是一个点周围的.
的个数
之后如果扫到标记过的点但是临点是加号那就以防万一再扫一次
然后就挂了🐶
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
ll t, n, m;
const int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
int main()
{
cin >> t;
while (t--)
{
cin >> n >> m;
bool M[n + 2][m + 2];
memset(M, 0, sizeof(M));
char a[n + 2][m + 2];
memset(a, 0, sizeof(0));
for (int i = 1; i <= n; i++)
scanf("%s", a[i] + 1);
bool flag = 0;
queue<pair<int, int>> q;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
if (a[i][j] == 'L')
{
q.push({i, j});
// M[i][j] = 1;
flag = 1;
break;
}
}
if (flag)
break;
}
while (q.size())
{
pair<int, int> now = q.front();
// if(M[now.first][now.second] == 1)
// {
// q.pop();
// continue;
// }
M[now.first][now.second] = 1;
// cout << "check " << now.first << ' ' << now.second << endl;
q.pop();
for (int k = 0; k < 4; k++)
{
pair<int, int> next(now.first + dx[k], now.second + dy[k]);
// cout << "round " << next.first << ' ' << next.second<<endl;
// cout << a[next.first][next.second] << ' ' << M[next.first][next.second] << endl;
if (next.first < 1 || next.second < 1 || next.first > n || next.second > m || a[next.first][next.second] == '#' )
continue;
if(M[next.first][next.second] == 1)
{
if(!(a[next.first][next.second]=='.'&&(a[now.first][now.second] == 'l'||a[now.first][now.second] =='L')))
continue;
}
// cout << "round xxx" << next.first << ' ' << next.second<<endl;
if (a[now.first][now.second] == 'L' || a[now.first][now.second] == 'l')
{
q.push(next);
int free = 0;
for (int j = 0; j < 4; j++)
{
pair<int, int> next2(next.first + dx[j], next.second + dy[j]);
if (a[next2.first][next2.second] == '.')
{
// cout << "dasdasdas " << next2.first << ' ' << next2.second<<endl;
free++;
}
}
if (free <= 1)
{
a[next.first][next.second] = 'l';
// cout << next.first << ' ' << next.second << ' ' << free << endl;
}
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
if (a[i][j] == 'l')
printf("+");
else
printf("%c", a[i][j]);
}
printf("\n");
}
}
return 0;
}
/*
1
3 2
.#
..
L.
*/