更好的阅读体验 \color{red}{更好的阅读体验} 更好的阅读体验


文章目录

  • A. 6男
  • B. 我要拿最多的Money2.0
  • C. 极致到完美的AK
  • D. 吃豆人
  • E. 胡辣汤啊胡辣汤
  • F. HF波那契数列
  • G. 小朱要解析密码
  • H. 苦命的毅哥

A. 6男


原题链接

题目大意

  • 给定一个字符串 S S S,求最长的连续的 6 6 6 的字串的长度。
  • S S S 可能含有空格。

思想

  • 签到题。
  • 读入时注意空格。

代码

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);void solve(){int res = 0;string s; getline(cin, s);for(int i = 0; i < s.size(); i ++){int cnt = 0;while(s[i] == '6'){cnt ++;if(i < s.size()); i ++;res = max(res, cnt);}}cout << res << endl;}int main(){IOS;int _ = 1;// cin >> _;while(_ --){solve();}return 0;}

B. 我要拿最多的Money2.0


原题链接

题目大意

  • 给定 n n n 行 m m m 列的矩阵,和 q q q 个坐标。
  • 以这些 q q q 个坐标为中心的点,曼哈顿距离小于等于 2 2 2 的点的金币无法得到。
  • 求剩余可以得到的点的金币的最大值。

思想

  • 签到题。
  • 通过偏移量数组枚举所有无法得到金币的坐标。
  • 除掉这些坐标后扫一遍,维护最值即可。

代码

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);const int N = 110;int mp[N][N];int n, m, q;bool check(int l, int r){if(l >= 0 && l < n && r >= 0 && r < m) return 1;return 0;
}int dx[] = {-2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int dy[] = {0, -1, 0, 1, -2, -1, 0, 1, 2, -1, 0, 1, 0};void st(int l, int r){for(int i = 0; i < 13; i ++){int x = l + dx[i], y = r + dy[i];if(check(x, y)) mp[x][y] = 0;  }
}void solve(){cin >> n >> m >> q;for(re int i = 0; i < n; i ++){for(re int j = 0; j < m; j ++){cin >> mp[i][j];}}while(q --){int l, r;cin >> l >> r;st(l, r);}int ans = 0;for(re int i = 0; i < n; i ++){for(re int j = 0; j < n; j ++){ans = max(ans, mp[i][j]);}}if(ans == 0) cout << -1 << endl;else cout << ans << endl;}int main(){IOS;int _ = 1;// cin >> _;while(_ --){solve();}return 0;}

C. 极致到完美的AK


原题链接

题目大意

  • 给定一个只包含 0 , 2 , 5 0,2,5 0,2,5 的字符串 S S S。
  • 对应若为 0 0 0 输出 5 5 5,若为 2 2 2 输出 0 0 0,若为 5 5 5 输出 2 2 2。

思想

  • 签到题。
  • 判断输出。

代码

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);const int N = 110;void solve(){string s; cin >> s;for(int i = 0; i < s.size(); i ++){if(s[i] == '5') cout << 2;else if(s[i] == '2') cout << 0;else if(s[i] == '0') cout << 5;}return ;}int main(){IOS;int _ = 1;// cin >> _;while(_ --){solve();}return 0;}

D. 吃豆人


原题链接

题目大意

  • 给定起始和终点坐标、矩阵的大小及障碍的坐标。
  • 判断在可以打破“空气墙”的情况下,能否到达终点。
  • “空气墙”的定义为非实心的连续块。

思想

  • 思维题。
  • 只要起点和终点的上下左右四个方向上有一处不存在障碍,就可以不断满足空气墙的条件,进而不断地打破墙。
  • 故只需要判断起点和终点的四个方向上的状态即可,另外注意起点和终点重合的情况。

代码

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);int n, m;int sx, sy, ex, ey;const int N = 100;char mp[N][N];bool vis1, vis2;int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};bool check(int l, int r){if(l >= 0 && l < n - 1 && r >= 0 && r < n - 1 && mp[l][r] != 'E') return 1;return 0;
}void solve(){cin >> sx >> sy >> ex >> ey;cin >> n >> m;for(int i = 0; i < n; i ++){for(int j = 0; j < n; j ++){mp[i][j] = '.';}}for(int i = 0; i < m; i ++){int x, y;cin >> x >> y;mp[x][y] = '*';}for(int i = 0; i < 4; i ++){int x = sx + dx[i], y = sy + dy[i];if(check(x, y)){if(mp[x][y] == '.'){vis1 = 1; break;}}}for(int i = 0; i < 4; i ++){int x = ex + dx[i], y = ey + dy[i];if(check(x, y)){if(mp[x][y] == '.'){vis2 = 1; break;}}}if(vis1 && vis2 || (sx == ex && sy == ey)) cout << "Yes!" << endl;else cout << "No!" << endl;}int main(){IOS;int _ = 1;// cin >> _;while(_ --){solve();}return 0;}

E. 胡辣汤啊胡辣汤


原题链接

题目大意

  • 给定矩形范围的左上角和右下角的坐标。
  • 判断若干点到该矩形边界的最短距离,输出最短距离的点的编号。

思想

  • 思维题。
  • 对于一个点,可以暴力枚举其到四条边的直线距离和到四个顶点的直线距离,取最小值即可。
  • 也可以通过粗略判断点的坐标关系,减少枚举和计算不必要的距离。

代码

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);const int N = 110;int n;double X1, X2, Y1, Y2, cnt = 1e8;bool check(int l, int r){double t = 1e8;if(l >= X1 && l <= X2) t = min(fabs(r - Y1), fabs(r - Y2));else if(r >= Y1 && r <= Y2) t = min(fabs(l - X1), fabs(l - X2));double p = min(min(sqrt((l - X1) * (l - X1) + (r - Y2) * (r - Y2)), sqrt((l - X1) * (l - X1) + (r - Y1) * (r - Y1))), min(sqrt((l - X2) * (l - X2) + (r - Y1) * (r - Y1)), sqrt((l - X2) * (l - X2) + (r - Y2) * (r - Y2))));if(cnt > min(t, p)){cnt = min(t, p);return 1;}return 0;
}void solve(){cin >> n;cin >> X1 >> Y1 >> X2 >> Y2;int num = INF;double res = 1e8;int flag = 0;for(int i = 1; i <= n; i ++){int l, r; cin >> l >> r;if(check(l, r)){flag = i; res = cnt;}}cout << flag << endl;}int main(){IOS;int _ = 1;// cin >> _;while(_ --){solve();}return 0;}

F. HF波那契数列


原题链接

题目大意

  • 类似斐波那契数列,构造 H F HF HF 波那契数列:
  • G n = G n − 1 + G n − 2 G_n = G_{n - 1} + G_{n - 2} Gn​=Gn−1​+Gn−2​
  • 其中 G 0 = 1 , G 2 = t ( 0 < t ) G_0 = 1,G_2 = t(0\lt t) G0​=1,G2​=t(0<t)
  • 给定 i i i 和 G i G_i Gi​,求满足条件的 G i m o d ( 19960515 ) G_i \mod(19960515) Gi​mod(19960515) 的值。
  • 若不存在,则输出 − 1 -1 −1。

思想

  • 思维题。
  • 列出部分 H F HF HF 波那契数列:
  • G 0 , G 1 , G 2 , G 3 , G 4 , G 5 … G_0,G_1,G_2,G_3,G_4,G_5\dots G0​,G1​,G2​,G3​,G4​,G5​…
  • 1 , t , t + 1 , 2 t + 1 , 3 t + 2 , 5 t + 3 … 1,t,t+1,2t+1,3t+2,5t+3\dots 1,t,t+1,2t+1,3t+2,5t+3…
  • 由此设 t t t 的系数为 x x x,常数项为 y y y,从第 i = 0 i=0 i=0 项开始,通过规律易知:
  • x x x 满足: 0 , 1 , 1 , 2 , 3 , 5 … 0,1,1,2,3,5\dots 0,1,1,2,3,5…, x x x 从 i = 1 i = 1 i=1 开始满足斐波那契数列。
  • y y y 满足: 0 , 0 , 1 , 1 , 2 , 3 … 0,0,1,1,2,3\dots 0,0,1,1,2,3…, y y y 从 i = 2 i = 2 i=2 开始满足斐波那契数列。
  • 则对于 G i G_i Gi​,我们可以通过上述关系求得对应的 t t t 值。
  • 由于数据范围很大,我们可以预处理出一定长度的斐波那契数列,不必递推求解上述关系。
  • 注意预处理的部分也要对 19960515 19960515 19960515 取模。

代码

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f, mod = 19960515;
const double eps = 1e-6, PI = acos(-1);int a[N];void solve(){LL i, g, j; cin >> i >> g >> j;LL t = (g  - a[i - 1]) / a[i];if(t <= 0 || (g  - a[i - 1]) % a[i]) cout << -1 << endl;else cout << ((a[j] * t) % mod + a[j - 1] % mod) % mod << endl;}int main(){IOS;int _ = 1;a[1] = 1;for(int i = 2; i <= N; i ++) a[i] = (a[i - 1] + a[i - 2]) % mod;cin >> _;while(_ --){solve();}return 0;}

G. 小朱要解析密码


原题链接

题目大意

  • 给定一串数字,输出其反转后不含前导零的形式。
  • 若为负数,则负号无需翻转,且 − 0 -0 −0 翻转后仍为 − 0 -0 −0。

思想

  • 模拟题。
  • 读入为字符串的形式,判断首元素是否为 -
  • 然后翻转该字符串,去除掉第一个非 0 0 0 数出现之前的前导 0 0 0,若所有的数全为 0 0 0,则只保留一个。

代码

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;const int N = 1e6 + 3;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);void solve(){string s; cin >> s;int flag = 0;if(s[0] == '-'){cout << '-';for(int i = 1; i < s.size(); i ++){if(s[i] != '0'){flag = i;break;}}if(flag == 0){cout << 0 << endl;return ;}}else{bool vis = 0;for(int i = 0; i < s.size(); i ++){if(s[i] != '0'){flag = i;vis = 1; break;}}if(!vis){cout << 0 << endl;return;}}reverse(s.begin(), s.end());for(int i = 0; i < s.size() - flag; i ++){if(i == 0) while(s[i] == '0') i ++;cout << s[i];}}int main(){IOS;int _ = 1;// cin >> _;while(_ --){solve();}return 0;}

H. 苦命的毅哥


原题链接

题目大意

  • 给定 n n n 个字符串,统计字符串 "我ZY就喜欢这个""我ZY实名邀请您于圣源二楼就餐" 出现的次数。
  • 分别输出对应次数,两者之和大于 3 3 3 时额外输出 6 6 6。

思想

  • 签到题。
  • 读入判断统计次数。
  • 注意直接复制题面的字符串即可。

代码

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>using namespace std;#define IOS ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define re register
#define fi first
#define se second
#define endl '\n'typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;const int N = 1e6 + 3;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-6, PI = acos(-1);void solve(){int t; cin >> t;int cnt1 = 0, cnt2 = 0;while(t --){string s; cin >> s;if(s == "我ZY就喜欢这个") cnt1 ++;if(s == "我ZY实名邀请您于圣源二楼就餐") cnt2 ++;}cout << cnt1 << " " << cnt2 << endl;if(cnt1 + cnt2 > 3) cout << 6 << endl;}int main(){IOS;int _ = 1;// cin >> _;while(_ --){solve();}return 0;}

河南工程学院2022级新生周赛(三)题解相关推荐

  1. Contest1003 - 河南工程学院2022级新生周赛(三)

    目录 1,6男 2,我要拿最多的money2.0 3,极致完美的AK 4,吃豆人 5,胡辣汤啊胡辣汤 6,HF波那契数列 7,小朱要解密码 8,苦命的毅哥 1,6男 题目描述 ZY看透了世态炎凉,对于 ...

  2. 题解:::Contest1001 - 河南工程学院2022级新生周赛(一)

    目录 1,1316: Hello , HAUE 2,P1317 - 我必须立刻签到,因为它有手就行http://www.haueacm.top/problem.php?id=1317 3, P1318 ...

  3. 计算机学院2022级新生周赛(一)题解

    更好的阅读体验\color{red}{更好的阅读体验}更好的阅读体验 另一篇题解\color{red}{另一篇题解}另一篇题解 文章目录 A. Hello , HAUE B. 我必须立刻签到,因为它有 ...

  4. 计算机学院2022级新生邀请赛(三)

    目录 我要拿最多的Money(命题人:张毅) 6男(命题人:朱奕锦) 极致到完美的AK(命题人:张毅) 胡辣汤啊胡辣汤(命题人:朱奕锦) 苦命的毅哥(命题人:朱奕锦) 小朱要解析密码(命题人:张毅) ...

  5. 计算机学院2022级新生邀请赛(二)

    目录 A:欢度国庆,来签个到吧 B:世界上背单词的最好方法 C:打印图形 D:国庆假期 E:有意义的天数 F:看实力OR看脸 G:ALL KILLED H:字符串 A:欢度国庆,来签个到吧 题目描述 ...

  6. 归来仍少年•青春不散场 | CEO刘其东出席同济经管学院2022级新生入学典礼及2022年毕业典礼

    2022年6月18日,"归来仍是少年"同济EMBA2022级线上迎新暨20周年系列活动(一)成功举办.出席活动的嘉宾有同济大学经济与管理学院党委书记施骞.同济大学经济与管理学院副院 ...

  7. 中南大学计算机院转专业要求,机电工程学院2018级本科学生转专业的实施细则...

    根据<中南大学本科生转专业实施办法>(中大教字[2018]58号).<中南大学本科生学籍管理规定>(中大教字[2017]41号),为鼓励学生个性发展,加强学生素质教育,特制定机 ...

  8. 武 学院2017级计算机专业,关注 | 计算机学院2017级新生见面会暨军训动员会顺利举行...

    原标题:关注 | 计算机学院2017级新生见面会暨军训动员会顺利举行 计算机学院记者团讯(通讯员 林雅南 编辑 要娅楠)9月1日晚7点,计算机学院2017级新生见面会暨军训动员会在大学生活动中心5楼举 ...

  9. 川师大计算机学院任教老师,全新启航,精彩蜕变——记四川师范大学计算机科学学院2019级新生开学典礼暨2019级新生学籍管理教育...

    朗朗金秋,丹桂飘香,2019级新生迎来了新的启航,即将实现新的精彩蜕变.2019年9月10日下午2:30,四川师范大学计算机科学学院2019级新生开学典礼暨2019级新生学籍管理专题教育在成龙校区学生 ...

最新文章

  1. constrain to margins
  2. Hystrix框架设计与实现
  3. [ADB]ADB(Android Debug Bridge)简介及基础(不包含命令)
  4. 网站开发中JS中的常用语句
  5. Linux 服务器停止当前运行的程序,实验,代码
  6. arduino loar_如何使用Arduino开发板制作函数生成器(波形发生器)
  7. 面试题45:圆圈中最后剩下的数字
  8. Nancy之从403到错误处理
  9. <2021SC@SDUSC> 开源游戏引擎 Overload 代码模块分析 之 OvTools(七)—— 终篇总结
  10. 范围查询-sql语句
  11. rpg制作大师_在线RPG大师班
  12. Android WebView下载apk
  13. 斐讯E1刷K2版老毛子Padavan,完美实现中继教程
  14. web标准和w3c_W3C记录了Web的体系结构
  15. WebDriverException: Message: unknown error: cannot find Chrome binary(ChromeDriver及谷歌官网下载地址)
  16. matlab y 0,用MATLAB算y-2y-3y=0的解
  17. 树莓派系列(一)-——————树莓派usb串口的使用
  18. 基于JSP的网上在线租车系统平台设计与实现
  19. java. int 高低位读取写,数字高位和低位,数据高低位
  20. 网际协议IP---ARP协议

热门文章

  1. 单源最短路径问题——分支限界法(Java)
  2. 软件测试——Mock的使用和测试
  3. 基于STM32与机智云平台的远程控制智能家居系统
  4. 房子装修有哪些注意事项要注意?
  5. WPF编程,TextBox回车换行的一种方法
  6. 白硕 | 知识图谱,就是场景的骨架和灵魂
  7. 技术的真相 I 618囤货在即,拯救“选择困难症”的虚拟试妆技术原理竟是...
  8. 009 如何更好地进行沟通
  9. C++ chrono
  10. Solidity基础入门知识(八)结构体structs