02 2020 档案
摘要:题意:给你三个点A(x,y),B(x,y),C(x,y),求∠ABC的度数,输出保留两位小数。 解法:余弦定理求出cos∠ABC的大小,根据PI=180°进行转换。 1 #include <stdio.h> 2 #include <math.h> 3 using namespace std; 4 f
阅读全文
摘要:题意:一个字符串的非空子串是指字符串中长度至少为1 的连续的一段字符组成的串。例如,字符串aaab 有非空子串a, b, aa, ab, aaa, aab, aaab,一共7 个。注意在计算时,只算本质不同的串的个数。请问,字符串0100110001010001 有多少个不同的非空子串? 1 #in
阅读全文
摘要:题意:打印字母X n=1 X n=2 X X X X X 对于给出的n,输出打印机n层打印结果( n<=7 ),输入多组数据,输入以 -1 结束 每组数据输出完毕,下行输出一个 "-"。 1 #include <iostream> 2 #include <algorithm> 3 #include
阅读全文
摘要:题意:两个数相加,计算A+B的和,输出每两组答案之间有个换行。 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <set> 5 #include <vector> 6 #include <map>
阅读全文
摘要:题意:有n个人一起吃饭,有些人相互认识,有些人不认识,认识的人只想和认识的人一起吃饭,不想和 陌生人一起吃饭,问需要几张桌子。 题解:并查集 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 con
阅读全文
摘要:A.Three Strings 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int N = 1e5 + 7; 5 const int inf = 0x3f3f3f3f; 6 cha
阅读全文
摘要:A.Erasing Zeroes 题解:暴力即可,统计区间1的0。 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 int t; 5 char s[110]; 6 int main() 7 { 8
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; typedef long long ll; int n,col; char c; int main() { std::ios::sync_with_stdio(false); cin.tie(0); std:
阅读全文
摘要:题解:签到题,直接输出题干要求。 #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { std::ios::sync_with_stdio(false); cin.tie(0); std::c
阅读全文
摘要:题解:两重循环,内层循环求阶乘的值,外层求和。 时间复杂度 O(n^2) 空间复杂度 O(n) #include <bits/stdc++.h> using namespace std; typedef long long ll; ll ans,n; int main() { std::ios::s
阅读全文
摘要:题解:快速幂,有人可能觉的水题没必要用快速幂,但是我认为写快速幂能更好的记住模板。 #include <bits/stdc++.h> using namespace std; typedef long long ll; ll ans,n; ll quickmi(ll a, ll n) // a:底数
阅读全文
摘要:PTA oj 不支持 gets() 函数wa了一发,粗略估计时间复杂度 O(n^2) 应该可以过 又wa 一发, 最后 O(n)时间做,多个 辅助空间的数组,空间复杂度多增加O(n),不过内存是足够的够,小问题。 #include <bits/stdc++.h> using namespace st
阅读全文
摘要:题解:用 sort函数,位于 <algorithm>中。 #include <bits/stdc++.h> using namespace std; typedef long long ll; int a[5]; int main() { for(int i = 0; i < 3; i++) cin
阅读全文
摘要:注意溢出问题,当时想着新生赛,应该不会有溢出的问题,白白贡献了一发wa,还有细节处理没处理好又白白贡献了 一发wa,这道题属于很简单的水题,有良好的代码习惯或者大量的编程一发即AC,我还是太菜了QAQ #include <bits/stdc++.h> using namespace std; typ
阅读全文
摘要:题意:给你两个整数a,b,计算a+b 的和是多少?(a>0,b>0) 题解:模拟加法 没压位 /*** 高精度加法:模拟计算 1.大整数存储: A3A2A1A0 A < 10 A:0~9 len(A) < 10 A:0~999999999 ***/ #include <iostream> #incl
阅读全文
摘要:题意: n 个点,m 条边,每条边的权值是 1,当输入的 n 是 0 时结束。 问两点之间最短距离的最大值是多少。 题解:BFS枚举每个点。 #include <iostream> #include <queue> #include <vector> #include <string> #inclu
阅读全文
摘要:题意:输入一个 n 行 m 列 的矩阵, 搜索有多少个连通 ‘W'字母块 题解:DFS。 有个疑惑,就是输入一个字符串AC,一个字母一个字母的输入会 wa 找Bug找了一个小时多,甚至怀疑过自己的算法写错了,现在都没想通 莫名其妙贡献的一发wa. 欢迎大佬看见能告诉我QAQ #include <io
阅读全文
摘要:题解:想象两只蚂蚁相遇后朝反方向走,如果无视不同蚂蚁的区别,可以认为是保持原样交错通过继续前进不会有任何问题,可 以认为蚂蚁是独立运动,求最长时间就是求蚂蚁到杆子端点的最大距离,求最短时间就是求蚂蚁到杆子端点的最短距离。 时间复杂度 O( n ) #include <iostream> #inclu
阅读全文
摘要:https://vjudge.net/problem/HDU-1240 题意:在一个三维空间中找条路线,是否能到达终点。 多组数据输入 第一行 Start N (一个N*N*N的三维空间) 输入这个三维空间。 'X'表示不可走 'O'表示可走 输入起点和终点 注意起点和终点是(y,z,x) 啊啊啊
阅读全文
摘要:bfs优先队列,把操作名称存入对应的下标,分六种情况讨论入队。 #include <iostream> #include <stdio.h> #include <queue> #include <vector> using namespace std; const int N = 110; int
阅读全文

浙公网安备 33010602011771号