蓝桥杯真题(更新中。。。)
2022/3/8 23:17:33
本文主要是介绍蓝桥杯真题(更新中。。。),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
时间显示【第十二届】【省赛】【B组】
【样例输入】
3 3
0 3
1 2
0 2
【样例输出】
3 1 2
【样例说明】
原数列为 (1, 2, 3)。 第 1 步后为 (3, 2, 1)。 第 2 步后为 (3, 1, 2)。 第 3 步后为 (3, 1, 2)。与第 2 步操作后相同,因为前两个数已经是降序了。
【评测用例规模与约定】
对于 30% 的评测用例,n, m ≤ 1000;
对于 60% 的评测用例,n, m ≤ 5000;
对于所有评测用例,1 ≤ n, m ≤ 100000,0 ≤ ai ≤ 1,1 ≤ bi ≤ n。
#include<iostream> #include<vector> #include<algorithm> using namespace std; int lst[100003]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) lst[i] = i + 1; vector<vector<int>> aa(m); for (int i = 0; i < m; i++) { aa[i].resize(2); } for (int i = 0; i < aa.size(); i++) for (int j = 0; j < aa[i].size(); j++) cin >> aa[i][j]; for (int i = 0; i < aa.size(); i++) { int t = aa[i][1]; if (aa[i][0] == 0) sort(lst, lst + t, greater<int>()); else if(aa[i][0]==1) sort(lst + t-1, lst + n,less<int>()); } for(int i=0;i<n;i++) cout << lst[i] << " "; return 0; }
只有60分,超时了!
试题 历届真题 时间显示【第十二届】【省赛】【B组】
#include<iostream> using namespace std; typedef long long LL; int main() { LL n; cin >> n; LL m_n = n / 1000; int ss = m_n % 60; int mm = m_n / 60 % 60; int hh = m_n / 3600 % 24; printf("%02d:%02d:%02d", hh, mm, ss); return 0; }
100分通过!
试题 历届真题 杨辉三角形【第十二届】【省赛】【B组】
#include<iostream> using namespace std; int lst[300][300] = { 0 }; int main() { int n; cin >> n; int count=3; int i, j; lst[1][1] = 1; lst[2][1] = 1; lst[2][2] = 1; if (n == 1) count = 1; else { for (i = 3; i < 300; i++) { for (j = 1; j < 300; j++) { lst[i][j] = lst[i - 1][j - 1] + lst[i - 1][j]; if (lst[i][j] != 0) count++; if (n == lst[i][j]) break; } if (n == lst[i][j]) break; } } cout << count << endl; return 0; }
40分,没看懂大佬们写的!哭死!
这篇关于蓝桥杯真题(更新中。。。)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-15鸿蒙生态设备数量超8亿台
- 2024-05-13TiDB + ES:转转业财系统亿级数据存储优化实践
- 2024-05-09“2024鸿蒙零基础快速实战-仿抖音App开发(ArkTS版)”实战课程已上线
- 2024-05-09聊聊如何通过arthas-tunnel-server来远程管理所有需要arthas监控的应用
- 2024-05-09log4j2这么配就对了
- 2024-05-09nginx修改Content-Type
- 2024-05-09Redis多数据源,看这篇就够了
- 2024-05-09Google Chrome驱动程序 124.0.6367.62(正式版本)去哪下载?
- 2024-05-09有没有大佬知道这种数据应该怎么抓取呀?
- 2024-05-09这种运行结果里的10.100000001,怎么能最快改成10.1?