合集-MyAlgorithmStudy
摘要:7-1 判断素数 题目分析 题目输入n个数,判断其是否为质数 对于判断质数,只需要满足从2开始遍历的每一个数一直到√n均无法被n整除即可 关于为什么只要到√n呢? 因为n = √n * √n,因此其最大的因数不会超过√n,因此可以优化减少不必要的循环 AC Code #include<iostrea
阅读全文
摘要:大整数的高精度运算 加法 #include <bits/stdc++.h> using namespace std; vector<int> big_num_add(vector<int> n1,vector<int> n2) { vector<int> ans; int t=0; for(int
阅读全文
摘要:PTA数组及排序查找题解与解题思路 函数题目 函数题目为平台提供的裁判程序调用所完成的函数进行判题,题目规定语言为C语言 6-1 求出二维数组的最大元素及其所在的坐标 本题较为简单,考察的是如何遍历一个二维数组,只需要两个循环依次遍历其每个维度和元素即可 如何寻找最大值?只需要在遍历每个元素的过程中
阅读全文
摘要:Educational Codeforces Round 160 (Rated for Div. 2) A. Rating Increase 纯暴力,分割字符串,如果n1<n2就输出,如果遍历完整个数组都不存在n1<n2就输出-1. const int N = 2e5 + 10; int toint
阅读全文
摘要:Codeforces Round 916 (Div. 3) (A~E2) A. Problemsolving Log 签到题,对于给出的字符串,用数组记录每个字母出现的次数,然后遍历一边记录数组,如果对应的字母出现次数大于它的位次,则说明该字母对应的题目被解出来了,最后输出解题数量即可 void s
阅读全文
摘要:代码宏定义以及框架约定 #include <bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // #define int long long #d
阅读全文
摘要:A.字符串拼接 直接拼接两个字符串即可,注意的是字符串可能包含空格,因此需要使用getline函数进行输入。 #include <bits/stdc++.h> using namespace std; int main() { string s1, s2; getline(cin, s1); get
阅读全文
摘要:2024 秋季PAT认证甲级(题解A-D) 写在前面 这一次PAT甲级应该是最近几次最简单的一次了,3个小时的比赛差不多30分钟就ak了(也是拿下了整场比赛的rk1),下面是题解报告,每个题目差不多都是20-30行代码,难度在洛谷普及组左右(cf 1000-1200分) A. A-1 Happy P
阅读全文
摘要:处理一行输入 C++的cin和C语言的scanf函数都以空格为分隔符,读取输入,每次读到空格或者换行符就会停止。因此,当我们要输出的一整行包含空格时,以上函数均无法得到正确的结果。 string s; cin >> s; cout << s; 输入: hello world 输出: hello 为了
阅读全文
摘要:A. Orange的作文排版 关于处理若干行输入,我们可以用while结合getline函数来完成,每次读取一行,就让行数+1,然后每次利用string的size方法得到当前行的列数,更新最长的列,最后得到答案。 #include<bits/stdc++.h> using namespace std
阅读全文
摘要:A. 左移 #include<bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while(T--) { string s; cin >> s; int ans = -1; if(s.front() == s.back
阅读全文
摘要:A. 早餐 print("39.20") B. 水论文 #define int long long signed main() { int n,k; cin >> n >> k; set<int> st; int ans = 0; st.insert(n); for(int i = 0, t = n
阅读全文
摘要:UPDATE update(2024/12/10) : 修正了E题代码的小错误,十分感谢 @Andyqian7 提供的hack数据! update(2024/12/15) : 修正了B题题解中存在问题的表述,十分感谢 @iy88 指出这个问题! 概述 本次重现赛已经上传到SYNU OJ,本校的同学可
阅读全文

浙公网安备 33010602011771号