2024东北邀请赛vp&补题记录
摘要
5题568罚时,遗憾铜首,连守银都不配了qwq
A题很简单但是细节一直没有处理好,最后对数器立大功。
对数器救队友于水火之中,但水火怎么来的你别问qwq
赛时部分
Problem J-Breakfast
签到
按题目要求输出答案即可。
#include<bits/stdc++.h>
using namespace std;
void test() {
cout << "39.20";
}
int main() {
int t=1;
// cin>>t;
while(t--) test();
return 0;
}
Problem D-nIMgAME
签到,博弈
模拟一下再加上点guess,大胆预测全是lose。
#include<bits/stdc++.h>
using namespace std;
void test() {
cout << "lose\n";
}
int main() {
int t=1;
cin>>t;
while(t--) test();
return 0;
}
Problem A-PaperWatering
数学,模拟
第一次操作后会出现两个数字,√x与x^2 ,可以知道在x^2的情况下一定会出现k个新的数字。而如果对x开根的结果向下取整了,那么这个新的数字的平方一定不等于x,因此第二次操作我们会得到 √(√x) 与 (√x)^2, 两个数字,而此时对这个数字在平方的方案中我们可以得到(k-1)个数字。按照这种方式模拟,如果开根得到1直接退出输出答案即可。
#include<bits/stdc++.h>
using namespace std;
void test() {
long long ans = 1;
set<long long> all;
int x, k;
cin >> x >> k;
if(k == 0) {cout << 1 << endl; return;}
for(int i = 0; i < k; i ++ ) {
if(x == 1) break;
if(all.find(1LL*x*x) == all.end()) {
ans += k-i;
}
all.insert(x);
ans++;
x = sqrt(x);
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t=1;
//cin>>t;
while(t--) test();
return 0;
}
Problem E-Checksum
位运算,枚举
题目有点绕,主要题意就是,构造一个字符串B,与A组成字符串 C = A+B,然后统计C中'1'的个数得到D,问是否存在一个二进制字符串B的整数表达与D只取前k位的整数表达相等。
题目要求构造k位的字符串B,也就是说B中1的个数最多只有k个,因此我们可以直接枚举从0到k的可能,按要求构造C并统计D,查看是否符合要求即可。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void print(int d, int k) {
if(d == 0) {
for(int i = 0; i < k; i ++ ) {
cout << 0;
}
cout << endl;
return;
}
vector<int> ans;
while(d) {
ans.push_back(d&1);
d >>= 1;
}
while(ans.size() < k) ans.push_back(0);
for(int k = ans.size()-1; k >= 0; k -- ) {
cout << ans[k];
}
cout << endl;
}
void test() {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int sum = count(s.begin(), s.end(), '1');
for(int i = 0; i <= k; i ++ ) {
int d = sum+i;
d %= (1 << k);
int one = __builtin_popcount(d);
if(one == i) {
print(d, k);
return;
}
}
cout << "None" << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t=1;
cin>>t;
while(t--) test();
return 0;
}
Problem L-BracketGeneration
栈,递推
赛时一直在从左往右推,浪费了很多时间。后面写出来之后已经没时间开H题了。
可以以第一种操作生成的字符串为基准,统计第二种操作可以从哪些状态转移而来。
容易知道,第二种操作只有在其包裹的所有连续括号对已经存在时才能进行,也就是说我们可以从后往前枚举,统计已经出现过的括号对,当枚举到第二种操作的括号对时,我们已经枚举过的每一个括号对在生成后的下一步都可以进行当前枚举到的括号对的插入操作。而从后面枚举时,处于后方的第二操作生成的括号对应当已经处理完毕,不会再因为递推过程而产生影响。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
void test() {
string str;
cin >> str;
stack<int> stk;
vector<int> list;
for(int i = 0; i < str.size(); i ++ ) {
if(str[i] == '(') {
stk.push(i);
} else {
if(stk.top() == i-1) {
list.push_back(0);
} else {
list.push_back(1);
}
stk.pop();
}
}
ll ans = 1;
int cnt = 0;
for(int i = list.size()-1; i >= 0; i -- ) {
cnt++;
if(list[i]) {
ans = ans*cnt%mod;
}
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t=1;
//cin>>t;
while(t--) test();
return 0;
}

浙公网安备 33010602011771号