当前位置:网站首页>第三届“传智杯”全国大学生IT技能大赛(初赛B组题解)
第三届“传智杯”全国大学生IT技能大赛(初赛B组题解)
2022-07-19 05:15:00 【星空皓月】
课程报名
思路
签到题:
直接模拟即可。
AC代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve() {
int n, v, m, a;
int cnt = 0, ans = 0;
scanf("%d%d%d%d", &n, &v, &m, &a);
for (int i = 1; i <= n; ++i) {
cnt++;
ans += v;
if (cnt == m) {
v += a;
cnt = 0;
}
}
printf("%d\n", ans);
}
int main () {
solve();
return 0;
}
期末考试成绩
思路
还是模拟
AC代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve() {
double x;
scanf("%lf", &x);
double ans = 0;
if (x >= 90) {
ans = 4.0;
} else if (x >= 60 && x < 90) {
ans = 4.0 - (90 - x) * 0.1;
} else {
int y = sqrt(x) * 10;
x = y;
if (x >= 60 && x < 90) {
ans = 4.0 - (90 - x) * 0.1;
} else {
ans = 0.0;
}
}
printf("%0.1f\n", ans);
}
int main () {
solve();
return 0;
}
志愿者
思路
简单排序,自定义排序规则。
AC代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5e5 + 5;
struct Node {
int t, k, ind;
}node[MAXN];
bool cmp(Node a, Node b) {
if (a.k * a.t == b.k * b.t) {
if (a.k == b.k) {
return a.ind < b.ind;
}
else {
return a.t > b.t;
}
}
return a.k * a.t > b.k * b.t;
}
void solve() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d%d", &node[i].t, &node[i].k);
node[i].ind = i;
}
sort(node + 1, node + n + 1, cmp);
for (int i = 1; i <= n; ++i) {
if (i == n) {
printf("%d\n", node[i].ind);
} else {
printf("%d ", node[i].ind);
}
}
}
int main () {
solve();
return 0;
}
终端
思路
利用两个map作映射关系,用时间去映射文件名,文件名去映射时间,一一对应。然后进行四个操作即可。
AC代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string, int> gt;
map<int, string> gf;
void solve() {
int n, cnt = 0;
cin >> n;
string f1, s1;
while(n--) {
cin >> f1;
if (f1[0] != 'l') {
cin >> s1;
if (f1 == "touch") {
if (!gt.count(s1)) {
gt[s1] = ++cnt;
gf[cnt] = s1;
}
} else if (f1 == "rename") {
string yyy;
cin >> yyy;
if (gt.count(s1) && gt.count(yyy) == 0) {
int t = gt[s1];
gf[t] = yyy;
gt.erase(s1);
gt[yyy] = t;
}
} else if (f1 == "rm"){
int t = gt[s1];
gt.erase(s1);
gf.erase(t);
}
} else {
for (map<int,string>::iterator it = gf.begin(); it!=gf.end(); ++it) {
cout << (it->second) << "\n";
}
}
}
}
int main () {
solve();
return 0;
}
运气
思路
简单搜索,枚举n位中的每一位的情况,最大递归次数为610 ≈ 6e7,递归不会爆,而且不需要取模,最大情况也就610。
AC代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
ll n, k, sum = 0;
void dfs(int cnt, ll num) {
if (cnt == n) {
if (num % k == 0) {
sum++;
}
return;
}
for (int i = 1; i <= 6; ++i) {
dfs(cnt + 1, num * 10 + i);
}
}
void solve() {
scanf("%lld%lld", &n, &k);
dfs(0 , 0);
printf("%lld\n", sum);
}
int main () {
solve();
return 0;
}
边栏推荐
- Pearson correlation coefficient and code implementation (C language +matlab)
- vivado2018.2版本带PS侧配置(bd)调用modelsim仿真时:(vlog-13006) Could not find the package (sc_util_v1_0_3_pkg)
- 离散数据(数组)的过零位置搜索
- Leetcode:905. 按奇偶排序数组【双指针+三种语言实现】
- 【Vscode配置Markdown环境】亲测好用~
- 全志 T507实现SPI转CAN 全过程
- Verilog HDL language summary (full)
- Redux 主要知识学习总结
- STM32 CubeIDE 断点失效的解决方法
- Definition, calculation method and relationship among linear convolution, cyclic convolution and periodic convolution
猜你喜欢
2022 -7-18 第八小组 顾宇佳 学习笔记
內網滲透隧道技術的相關知識
【Vscode配置Markdown环境】亲测好用~
雷达基础系列文章之五:雷达调制样式的功能
代码审计之oasys系统
Detailed explanation of the principle of triode series linear voltage stabilizing circuit and Multisim Simulation
The Debian system is ported with USBWiFi rtl8192eu driver and set to start automatically
小波分析之多分辨率分解和重构过程详解
Typical HMI application implementation scheme can help you better carry out master control selection
Quanzhi t507 realizes the whole process of SPI to can
随机推荐
Stm32f4 PWM capture (rising edge / falling edge / high and low level time) detailed explanation (including code)
Code audit system
Openstack uses dashboard to perform image operations, manage instances, and other operations
Infrared decoding program based on timer capture function (NEC protocol)
Xilinx 7 Series primitive use (clock related) - (I)
How to put a "platform" into a small box? (Part 2) technical realization
PCB在导出gerber文件时过孔盖油设置方法
Experience of installing ROS in Jetson nano (failed)
Common ports and vulnerabilities
基于ARM核心板实现的核酸自动提取仪
Solution to the problem of constantly popping up blank web pages when opening OrCAD capture CIS in cadence 17.2
vivado工程版本升级时相关IP版本IP Status显示Using cached IP results
代码审计之oasys系统
常见设备默认口令
The end result of printf - where is the data printed
Evaluate reading and writing speed and network of Reza rz/g2l storage
[markdown] about markdown, I want to say this~
How to test the availability and stability of EIM bus
FPGA skimming P4: use 8-3 priority encoder to realize 16-4 priority encoder, use 3-8 decoder to realize full subtracter, realize 3-8 decoder, use 3-8 decoder to realize logic function, and use data se
皮尔逊相关系数及代码实现(C语言+MATLAB)