- 博客(29)
- 收藏
- 关注
原创 洛谷 P2010 [NOIP2016 普及组] 回文日期
(不用判断闰年,因为0229反过来就是9220为闰年,其余日期都很普通不用判断)。相比于枚举区间内所有字符串来判断是不是回文串,不如。构造回文串可以由前四位生成后四位,也可以。了(n
2023-01-13 14:41:53
519
原创 B - Madoka and the Elegant Gift
题主做法(稍复杂):bfs每一个连通块,取到连通块中的所有点的横纵坐标,记录最大横纵坐标和最小横纵坐标,圈出”标准矩形“,若连通块中点的数量与“标准矩形的数量相同,那么这个连通块是矩形。大佬做法:遍历图中每一个”0“点,若它所在2 * 2 方格中有 3 个 ”1“点, 那么图中就存在不是矩形的连通块。(ps:瞎写个对拍,还挺好玩hhhhh,妈妈再也不用担心WA题没数据了)题主在实现中出现的问题:在bfs时没有考虑向上向左遍历点的情况。给定一个n行m列的01图,判断图中的”1“连通块是否都为矩形。
2022-08-19 20:22:24
267
原创 D1. Mocha and Diana (Easy Version)(并查集判环)
有小A和小B,他们两个各有一个森林(无向无环图)(可能有孤立点),两个森林中n个节点都相互对应,已知两个森林的边的连接情况,进行添加边的操作(两森林添加一样的边,并保证添加边后两森林还是森林),求能连接边的条数的最大值。森林是无向无环图,森林中有n个节点,那么森林中至多有n-1条边。(如果要连的这条边的两个端点是同一个集合中的,那么这条边连接会使图中出现环),其中m1为小A森林中边的个数,m2为小B森林中边的个数。那么要想得到连边数的最大值,要连的线段条数为。...
2022-07-14 20:55:27
344
原创 ABC257 C - Robot Takahashi
题目大意:已知一列人的身份(1:大孩 0:小孩)和 weight 值,这里想让机器人通过划分weight值界限区分大孩和小孩(>=standard :大孩
2022-07-06 21:50:24
511
原创 蓝桥 X进制减法
//注:进制:逢几进一,每一位的进制可以不同#include <iostream>//思路:某一位上, max == 两个数在这一位上的更大的那个数 ,这一位进制最小为 max + 1(max == 0 时,进制为最小进制 2 ) //X进制数计算: r1 * 1 + r2 * a[1] + r3 * a[1] * a[2] + ··· + rn * a[1] * a[2] * ··· * a[n - 1] ...
2022-05-10 20:03:10
233
原创 天梯练习 7-9 估值一亿的AI核心代码
#include<iostream>#include<algorithm>#include<string>#include<cstring>using namespace std;int main(){ int n; cin >> n; getchar(); while(n -- ) { string str; getline(cin, str); .
2022-04-22 22:04:57
96
原创 天梯练习 7-19 福到了
#include <iostream>using namespace std;char a[110][110];int main(){ char c; int n; cin >> c >> n; getchar(); for(int i = 1; i <= n; i ++ ){ for(int j = 1; j <= n; j ++ ){ scanf("%c.
2022-04-22 21:49:18
90
原创 天梯练习 7-15 倒数第N个字符串
#include <iostream>#include <cmath>#include <cstring>using namespace std;int main(){ int m, n; scanf("%d %d", &m, &n); string a; int b, c; for(int i = 0; i < m; i ++ ){ a += 'z'; } .
2022-04-22 18:32:23
328
原创 天梯练习 7-8 阅览室
#include <iostream>#include <cstring>using namespace std;bool book[1010];int starttime[1010];int time(string s){ int a = (s[0] - '0') * 10 + (s[1] - '0'); int b = (s[3] - '0') * 10 + (s[4] - '0'); return a * 60 + b; }int .
2022-04-22 18:19:27
193
原创 天梯练习 7-4 古风排版
#include <iostream>#include <cstring>using namespace std;char a[110][110];//输出的答案int main(){ int k; cin >> k; getchar();//读入int后不吞掉回车 string s; getline(cin, s); int n = s.size() / k; if(s.size() % .
2022-04-22 18:16:05
106
原创 天梯练习 7-18 帅到没朋友
#include <iostream>#include <cstring>#include <iomanip>using namespace std;bool b[100010] = {0};//这个人有没有朋友圈bool ans[100010] = {0};//这个人有没有统计过bool success = true;int main(){ int n, m; cin >> n; for(int i = 1; i.
2022-04-22 18:10:39
89
原创 天梯练习 7-12 一帮一
#include <iostream>//双指针#include <cstring>using namespace std;int n;string s[60];int sex[60];int t0, t1;int b[60] = {0};int main(){ cin >> n; for(int i = 1; i <= n; i ++ ){ cin >> sex[i] >> s[i];.
2022-04-22 18:04:52
83
原创 天梯练习 7-9 出租
#include <iostream>#include <string>#include <algorithm>using namespace std;const int N = 15;bool b[N];//有没有存过这个数字int a[N], cnt = -1;//存下的无重复的可能的数字int re[N];//每个数字对应在a[]中的角标bool cmp(int a, int b){ return a > b;}int .
2022-04-22 17:56:29
204
原创 天梯练习 7-7 正整数A+B
#include <iostream>#include <cstring>//易错:第一个空格后面的所有字符都属于字符串Busing namespace std;bool Isgood(string s){ bool success = true; if(s[0] == ' ') success = false; for(int i = 0; i < s.size(); i ++ ){ if(s[i] &l.
2022-04-22 17:53:22
154
原创 天梯练习 7-9 N个数求和
#include<iostream>using namespace std;typedef long long LL;LL gcd(LL a, LL b){ return b ? gcd(b, a % b) : a;}int main(){ LL N = 0, a = 0, b = 0, sum_a = 0, sum_b = 1, t; scanf("%lld", &N); for (int i = 0; i < N; i++) { scanf(.
2022-04-22 17:40:41
161
原创 天梯练习 7-6 连续因子
#include <iostream>#include <cmath>using namespace std;typedef long long LL;LL N;LL s;//答案序列的起始点LL len = 0;//连续因子最大长度int main(){ cin >> N; s = N;//如果没有连续子序列,序列为它本身 for(int i = 2; i <= sqrt(N); i ++ ){.
2022-04-22 15:51:22
110
原创 天梯练习 7-2 打印沙漏
#include <iostream>using namespace std;int main(){ int N, n; char c; cin >> N; getchar();//细节 cin >> c; for(int i = 1;; i ++ ){//n: 确定沙漏的大小 最后输出 2 * n + 1 行 if(2 * i * i - 1 > N){ .
2022-04-22 15:48:04
128
原创 天梯练习 7-2 重排链表
输出时,依据编号获得对应的值#include <iostream>#include <iomanip>using namespace std;const int N = 100010;int st, n;int e[N], ne[N];int a[N], cnt;//按链表遍历顺序存每个数的编号void add(int x, int y, int w){ e[x] = w, ne[x] = y;}int main(){ cin &g.
2022-04-21 16:35:56
1874
原创 天梯练习 7-20 简单计算器
这个题目可能有些问题,“直到两个堆栈都为空时,计算结束”,如果top1 || top2 会出现段错误实际上题目下如果所有计算都是合法的,最后一定是sta中剩余一个数,就是最终的结果,staa为空。#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int N = 1010;int n;int sta[N], top1;char
2022-04-21 16:31:30
171
原创 天梯练习 7-19 清点代码库
18分暴力枚举//超时两个点#include <iostream>#include <cstring>#include <algorithm>#include <vector>using namespace std;const int N = 100010;int n, m;struct node{ int sum = 0; vector<int> v;}da[N];int cnt;//答案数据总数
2022-04-21 15:40:57
226
原创 6-3 【CPP0005】定义日期类Date PTA
嗯,很难搞的一道题代码:(函数填充部分)#include <iomanip>class Date{private: int year, month, day;public: Date(int a = 1,int b = 1,int c = 1){ if(month > 12) month = 12; if(month < 1) month = 1; if(day > monthDay[mon
2022-03-28 20:04:35
746
原创 2022.3.22 CF练习赛(待解决)
正解:#include <iostream>#include <cmath> using namespace std; int T;double a, b; int main(){ cin >> T; while(T -- ){ cin >> a >> b; double u = sqrt(a * a + b * b); if(!u) cou...
2022-03-23 12:45:56
261
原创 欧拉函数(学习笔记)
一、欧拉函数定义:对于一个正整数 n ,小于 n 且和 n 互质的正整数(包括 1 )的个数,记作φ ( n ) 。(互质理解:一个当分子,一个当分母,此分式不可化简)二、欧拉函数通式:φ(n)=n*(1-1/p1)(1-1/p2)(1-1/p3)*(1-1/p4)……(1-1/pn)其中p1, p2……pn为n的所有质因数,n是不为0的整数。三、推导、结论:1. φ( 1 )= 12. p 为质数,则 φ( p )= p - 13. p ,q 都为质数,则 φ(
2022-01-24 18:15:15
1405
原创 cout的常见用法
1.进制转换(见另一篇blog)C++ cout转换进制输出_m0_45400399的博客-优快云博客2.设置填充字符setfill()(摘自百度知道)打印结果3.强制显示小数点和无效0setiosflags(ios::showpoint),强制显示正负号setiosflags(ios::showpos);(摘自百度知道)打印结果4.设置小数位数setprecision():保留n位有效数字,(若前面整数位数大于 n 位,使用科学计数法输出)(摘自百度...
2022-01-21 12:54:01
14870
原创 时间的换算(时、分、秒、毫秒、微秒、纳秒)
1 时 = 60 分1 分 = 60 秒1 秒 = 1000 毫秒1 毫秒 = 1000 微秒1 微秒 = 1000 纳秒
2022-01-21 11:10:56
22574
原创 C++ cout转换进制输出
cout 指示十进制输出: deccout指示十六进制输出:hexcout指示八进制输出: oct(以上三种转换头文件为<iostream>)cout指示二进制输出: bitset<num>(以上一种转换头文件为<bitset>)#include<iostream>#include<bitset>using namespace std;int main(){ int a = 66; c...
2022-01-20 17:07:58
3465
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人