我真傻,真的,填空题居然选择手推。
A
//战斗吧!战斗吧!
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mm(a, b) memset(a, b, sizeof(a))
#define inf 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
//unordered_map<int , int > bj;//priority_queue<int,vector<int>,less<int> > pq
typedef long long ll;
typedef pair<int , int> PII;
int main()
{
int ans = 0;
for(int i = 1;i <= 2021;i ++)
{
int t = i;
while(t)
{
if(t % 10 == 6) ans ++;
t = t / 10;
}
}
cout << ans;
return 0;
}
B
//战斗吧!战斗吧!
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mm(a, b) memset(a, b, sizeof(a))
#define inf 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
//unordered_map<int , int > bj;//priority_queue<int,vector<int>,less<int> > pq
typedef long long ll;
typedef pair<int , int> PII;
//string s;
string s = "iawaswapwauawhawdwafwanbiopwanivgbikvblvbwawawawvolyuvgbololvolgbyolgyowagbolgawgboplwawaolgyolwaogblwaygbowawagwabwayawopwawagyowabwaowapjwapcfrtuywawacvujwawawaufttyfuftywawawatifgugbgbyguwawawawayugbigwwwytigwygwgbwyoawawgoghwaogwborgrewabouyhwabyuhowabhnwawauygbawyawuwaoawfcawaaaahwaywauwagwawefwaafmbawklawjiawihnwanhawawawawijwajiofjeriofgjrefjhwaewarwaowagwahwauwaiwarwaiwaqwarwahwaqwawwaowapfweofbwewafwahwaiwaewawwawawawawafwawawawaeiufwepfhnewfwahwajwatwafowawajtokshwawafwaiwahwafwahmgoewawawawafkfjkewnwawafiewhfwawawafjkernhawkrenwawawawafujnrheiowanwakawawawawwanoifewajrwaoawawfweojnwawawawawawawafjkwenawawferkwmpwawawawaforeijawawferhfiueorghwuwafguwegfwaghrwiufgwahweofgowaidwiweaiwwawieyiwe";
int main()
{
// cin >> s;
int ans1 = 0;
int ans2 = 0;
vector<char> st;
int len = s.size();
// cout << s << endl;
// cout << len << endl;
for(int i = 0;i < len;i ++)
{
// cout << st.size() << endl;
if(st.empty())
{
if(s[i]=='a' || s[i]=='w') st.push_back(s[i]);
}
else
{
char now = st.back();
if(now == 'a')
{
if(s[i] == 'w') st.push_back(s[i]);
else
{
if(s[i] == 'a')i --;
if(st.size() == 2 || st.size() == 3) ans1 ++;
else if(st.size() > 3) ans2 ++;
st.clear();
}
}
if(now == 'w')
{
if(s[i] == 'a') st.push_back(s[i]);
else
{
if(s[i] == 'w') i --;
if(st.size() == 2 || st.size() == 3) ans1 ++;
else if(st.size() > 3) ans2 ++;
st.clear();
}
}
}
}
if(st.size() > 3) ans2 ++;
else if(st.size() == 2 || st.size() == 3) ans1++;
cout << ans1 << endl << ans2;
return 0;
}
C
//战斗吧!战斗吧!
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mm(a, b) memset(a, b, sizeof(a))
#define inf 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
//unordered_map<int , int > bj;//priority_queue<int,vector<int>,less<int> > pq
typedef long long ll;
typedef pair<int , int> PII;
const int N = 20;
int f[N];
ll ff[N];
void init()
{
f[1] = 1;
f[2] = 1;
for(int i = 3;i <= 15;i ++)
{
f[i] = f[i - 1] + f[i - 2];
// cout << f[i] << endl;
}
for(int i = 1;i <= 15;i ++)
{
ff[i] = f[i] * f[i + 1];
// cout << ff[i] << endl;
}
}
ll lcm(ll a , ll b)
{
//ll ans = a * b;
return __gcd(a , b);
}
int main()
{
init();
ll zi = 5;
ll mu = 3;
for(int i = 4;i <= 13;i ++)
{
zi = mu + zi * ff[i];
mu = mu * ff[i];
ll yue = lcm(zi , mu);
zi = zi / yue;
mu = mu / yue;
}
cout << zi << "/" << mu << endl;
return 0;
}
D
//读错题的我是sb
//战斗吧!战斗吧!
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mm(a, b) memset(a, b, sizeof(a))
#define inf 0x3f3f3f3f
#define lowbit(x) (x&(-x))
using namespace std;
//unordered_map<int , int > bj;//priority_queue<int,vector<int>,less<int> > pq
typedef long long ll;
typedef pair<int , int> PII;
int a[] = {2, 3, 3, 3, 5, 6, 6, 7, 7, 8};
bool ff(int l , int r)
{
if(r - l <= 1) return true;
int ans1 = 0 , ans2 = 0;
for(int i = l + 1;i <= r;i ++)
{
if(a[i] - a[i - 1] > 0) ans1 ++;
if(a[i] - a[i - 1] < 0) ans2 ++;
}
if(ans1 == 0 || ans2 == 0)
{
//for(int i = l;i <= r;i ++) cout << a[i] << " ";
// cout << endl;
return true;
}
return false;
}
int main()
{
int ans = 0;
do
{
bool flag = false;
for(int i = 0;i <= 7;i ++)
{
for(int j = i + 1;j <= 8;j ++)
{
//第一个的长度是 i | 0 ,i -1
//第二个的长度是 j | i ,i + j - 1;
//第三个的长度是 10 - i - j | i + j , 9;
if(ff(0 , i) && ff(i + 1 , j) && ff(j + 1 , 9))
{
ans ++ ;
flag = true;
break;
}
}
if(flag) break;
}
}while(next_permutation(a , a + 10));
cout << ans;
return 0;
}
E
F
G
H
I
J
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010, M = 200010, INF = 0x3f3f3f3f;
int n, m;
int p[N];
struct Edge
{
int a, b, w;
bool operator< (const Edge &W)const
{
return w < W.w;
}
}edges[M];
int find(int x)
{
if (p[x] != x) p[x] = find(p[x]);
return p[x];
}
void kruskal()
{
sort(edges, edges + m);
for (int i = 1; i <= n; i ++ ) p[i] = i; // 初始化并查集
int res = 0, cnt = 0;
for (int i = 0; i < m; i ++ )
{
int a = edges[i].a, b = edges[i].b, w = edges[i].w;
a = find(a), b = find(b);
if (a != b)
{
p[a] = b;
// res += w;
cnt ++ ;
if(cnt == n - 1)
{
cout << w;
return ;
}
}
}
cout << -1;
return ;
// if (cnt < n - 1) return INF;
// return res;
}
int main()
{
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i ++ )
{
int a, b, w;
scanf("%d%d%d", &a, &b, &w);
edges[i] = {a, b, w};
}
kruskal();
return 0;
}