当前位置:网站首页>The third "intelligence Cup" National College Students' IT skills competition (solution to group B of the preliminary competition)
The third "intelligence Cup" National College Students' IT skills competition (solution to group B of the preliminary competition)
2022-07-20 10:02:00 【Starry sky and bright moon】
Course registration
Ideas
Sign in problem :
It can be simulated directly .
AC Code
#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;
}
Final exam results
Ideas
Or simulation
AC Code
#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;
}
volunteer
Ideas
Simple order , Custom collation .
AC Code
#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;
}
terminal
Ideas
Use two map Make mapping relationship , Take time to map file names , File name demapping time , One-to-one correspondence . Then carry out four operations .
AC Code
#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;
}
luck
Ideas
Simple search , enumeration n The situation of each bit , The maximum number of recursion is 610 ≈ 6e7, Recursion will not explode , And there is no need to take a mold , The biggest case is 610.
AC Code
#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;
}
边栏推荐
- PCL基本操作大全
- FPGA network port implementation and detailed explanation (3)
- G2l series core board -rz/g2l processor introduction | frame diagram | power consumption | schematic diagram and hardware design guide
- 如何把一个“平台” 塞进一个小盒子里?(下)|技术实现篇
- 内网渗透隧道技术的相关知识
- Pearson correlation coefficient and code implementation (C language +matlab)
- 解决问题phpstudy导入数据库失败
- The end result of printf - where is the data printed
- Evaluate reading and writing speed and network of Reza rz/g2l storage
- FPGA -- detailed explanation of the principle of displaying images with VGA timing (2)
猜你喜欢
Typical HMI application implementation scheme can help you better carry out master control selection
First hand evaluation of Reza g2l core board and development board
Automatic nucleic acid extraction instrument based on ARM core board
vulnhub 靶机 Jangow: 1.0.1
线性卷积、循环卷积、周期卷积的定义、计算方法及三者之间的关系
SCU of zynq ARM core
How to put a "platform" into a small box? (I) scheme comparison
详细讲解JS中的加法(+)运算,基本数据类型相加,引用数据类型相加底层的运算规则,[]+{},{}+[]
How to put a "platform" into a small box? (Part 2) technical realization
STM32 CubeIDE 断点失效的解决方法
随机推荐
(data and electricity) summary of various triggers - FPGA octet (1)
Experience of installing ROS in Jetson nano (failed)
Ktor 2.0?半香不香的尴尬
乐山师范程序设计大赛2020- H: 最小公倍数【求因子个数】
FPGA skimming p2: multifunctional data processor, calculate the difference between two numbers, use generate For statement simplifies the code, uses sub modules to realize the size comparison of three
Log access development with one person per day and nine people per day -- project development practice based on instruction set Internet of things operating system
Default password of common devices
Least square linear fitting and its code implementation (C language)
Ktor 2.0? Half fragrant embarrassment
线性卷积、循环卷积、周期卷积的定义、计算方法及三者之间的关系
经纬度及其与坐标系的转换
Stm32f4 PWM capture (rising edge / falling edge / high and low level time) detailed explanation (including code)
Leetcode:20. 有效的括号【三种思路+不同语言实现】
Evaluate reading and writing speed and network of Reza rz/g2l storage
上海二工大 - 健康日报AutoCheck
Precautions for the selection and conversion of single power supply operational amplifier and dual power supply operational amplifier and their power supply mode
【OpenCV】边缘检测 [API与源码实现]
TCP three handshakes and four swings
FPGA skimming P3: 4-bit numeric comparator circuit, 4bit carry ahead adder circuit, priority encoder circuit, priority encoder
The Debian system is ported with USBWiFi rtl8192eu driver and set to start automatically