第十二届蓝桥杯大赛软件赛省赛(2021年)
发布时间
阅读量:
阅读量
填空(45分):
1.描述(直接打出来)5 √
2.枚举+模拟(直接暴力)5 √
3.高精度+直线定义(有难度)10 **
4.数学问题之约数(直接枚举约数)10 √
5.最短路径(Kruskal算法,或者Fold算法)15 √
编程(105分):
1.时间显示(直接模拟)15 √
2.砝码称重(背包问题,滚动数组,直接没)20 **
3.杨辉三角形(递归+找规律,找不出来直接没)20 **
4.双向排序(找规律,直接没)25 ×
5.括号匹配(dp,直接没)25 ×
2.卡片
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int s[10];
bool check(int x){
while(x){
int t = x % 10;
x /= 10;
if(-- s[t] < 0) return false;
}
return true;
}
int main(){
for(int i = 0; i < 10; i++){
s[i] = 2021;
}
for(int i = 1; ; i++)
if(!check(i)){
cout << i - 1 << endl;
return 0;
}
return 0;
}
4.仓库摆放
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
int main()
{
long long n;
n = 2021041820210418;
vector<LL> d;
for(LL i = 1; i * i <= n; i++)
if(n % i == 0)
{
d.push_back(i);
if(n / i != i) d.push_back(n / i);
}
int res = 0;
for(auto a : d)
for(auto b : d)
for(auto c : d)
if(a * b * c == n)
res ++;
cout << res <<endl;
return 0;
}
1.时间显示
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int main()
{
LL n;
cin >> n;
n /= 1000;
n %= 86400;
int h = n / 3600;
n %= 3600;
int m = n / 60;
int s = n % 60;
printf("%0.2d:%0.2d:%0.2d",h,m,s);
return 0;
}
全部评论 (0)
还没有任何评论哟~
