- 博客(60)
- 资源 (2)
- 收藏
- 关注
原创 杭电OJ 1196(C++)
基础题。#include <iostream>#include <cstring>#include <cmath>using namespace std;int main(){ int A; char bit[10]; //A转换的二进制数 while (cin >> A) { if (A == 0) break;...
2020-02-29 21:40:31 221
转载 杭电OJ 1195(C++)
#include <iostream>#include <cstring>#include <queue>using namespace std;char start[5], password[5]; //起始密码,正确密码int vis[10000]; //每个四位数的访问情况struct node{ char str[5]; //密码...
2020-02-29 21:30:31 272
原创 杭电OJ 1194(C++)
基础题。#include <iostream>#include <algorithm>using namespace std;int main(){ int n; cin >> n; int s, d; //和,差 int a, b; //分数 while (n--) { cin >> s >> d; ...
2020-02-29 15:50:51 183
原创 杭电OJ 1181(C++)
基础深搜题。#include <iostream>#include <cstring>using namespace std;const int MAXN = 1000;int flag;int vis[MAXN]; //访问情况int mp[MAXN][MAXN]; //单词首尾对应情况//深搜void dfs(int x){ if (x =...
2020-02-29 11:44:56 168
转载 杭电OJ 1180(C++)
#include <iostream>#include <cstring>#include <queue>using namespace std;struct Node{ int t; //当前步数 int x; //当前x坐标 int y; //当前y坐标};int M, N; //行数,列数char mp[24][24]; //地...
2020-02-29 10:30:51 253
原创 杭电OJ 1179(C++)
计算二分图最大匹配,套用标准模板即可。#include <iostream>#include <cstring>using namespace std;const int MAXN = 210;bool vis[MAXN], mp[MAXN][MAXN]; //结点访问数组,各结点之间有无连接int link[MAXN]; //结点匹配数组int n, ...
2020-02-28 20:50:00 134
原创 杭电OJ 1178(C++)
基础题。求 1+ 3 + 6 + ... + i(i +1)/2 的和,求和公式为 N* (N+1) * (N+2) / 6,对其取 10 的对数,确定 E 后面的数字。#include <iostream>#include <cmath>#include <iomanip>using namespace std;int main(){ ...
2020-02-28 20:00:00 269
原创 杭电OJ 1177(C++)
基础题,结构体排序。首先读入所有选手的解题数量和用时,将用时转换为秒。然后排序,解题数量不同时,解题数量多的排在前面;解题数量相同时,用时少的排在前面。最后根据金银铜牌数量和选手所在名次决定输出。#include <iostream>#include <string>#include <algorithm>using namespace ...
2020-02-28 19:40:00 167
原创 杭电OJ 1176(C++)
基础动态规划题。设 dp[i][j] 表示从 i 时刻 j 位置开始,最终能接到的最大馅饼数。dp[i][j] = max(dp[i + 1][j + 1], dp[i + 1][j], dp[i + 1][j - 1]) + 原本的dp[i][j]#include <cstdio>#include <cstring>#include <algorith...
2020-02-28 18:18:18 284
转载 杭电OJ 1175(C++)
#include <iostream>#include <cstring>using namespace std;const int MAXN = 1005;int maze[MAXN][MAXN]; //迷宫数组bool vis[MAXN][MAXN]; //访问数组bool flag; //是否能消除int n, m, q; //输入int sx, ...
2020-02-28 14:30:00 393
转载 杭电OJ 1174(C++)
#include <iostream>#include <cmath>using namespace std;int main(){ int T; cin >> T; double h1, r1, x1, y1, z1; double h2, r2, x2, y2, z2, x3, y3, z3; double a, b, c, x, y,...
2020-02-27 20:30:40 395
原创 杭电OJ 1173(C++)
基础题。基地的X坐标为所有点X坐标的中位数,Y坐标为所有点Y坐标的中位数。#include <iostream>#include <algorithm>#include <iomanip>using namespace std;const int MAXN = 1000005;double x[MAXN];double y[MAXN];i...
2020-02-27 19:00:00 163
原创 杭电OJ 1172(C++)
本题给的时间非常充裕,所以采用暴力破解。依次判断 1000 ~ 9999 中满足所有猜测的数的个数。如果恰好为1,则猜测成功;否则无法猜测。#include <iostream>#include <algorithm>using namespace std;const int BASE = 10;const int MAXN = 100;int A[M...
2020-02-27 17:50:00 888
原创 杭电OJ 1171(C++)
0-1背包,套用标准模板即可。#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 5000005;int value[MAXN]; //物品价值int dp[MAXN]; //背包内物品最大价值,dp[i]表示...
2020-02-27 16:50:00 186
原创 杭电OJ 1070(C++)
基础题。#include <iostream>#include <iomanip>using namespace std;int main(){ int T; cin >> T; char op; 运算符 int a, b; 操作数 while (T--) { cin >> op >> a >>...
2020-02-27 15:20:56 234
原创 杭电OJ 1166(C++)
使用线段树模板即可。由于本题输入数据量极大,所以必须使用 scanf 输入,使用 cin 会超时。#include <cstdio>#include <cstring>const int MAXN = 50005;int tree[MAXN << 2];int num[MAXN];char s[7];int L, R, C; //L,R为修改...
2020-02-27 13:00:14 188
转载 杭电OJ 1165(C++)
#include <iostream>using namespace std;const int MAXN = 1000000;int d[4][MAXN + 5];int main(){ d[0][0] = 1; //m = 0 d[1][0] = 2; d[2][0] = 3; d[3][0] = 5; //m > 0, n = 0 fo...
2020-02-26 21:40:00 228
原创 杭电OJ 1164(C++)
基础题。#include<iostream>using namespace std;int main(){ int n; while (cin >> n) { int i; for (i = 2; i <= n; i++) { if (n % i == 0)...
2020-02-26 21:00:00 239
转载 杭电OJ 1163(C++)
#include<iostream>using namespace std;int main(){ int n; while (cin >> n) { if (n == 0) break; int sum = 1; for (int i = 1; i <= n; ...
2020-02-26 20:30:00 249
原创 杭电OJ 1162(C++)
计算最小生成树的总长度,使用 Kruskal算法。#include <iostream>#include <algorithm>#include <iomanip>using namespace std;const int MAXN = 105;int n; //点的数量int m; //线的数量int fa[MAXN]; //父结点数组,...
2020-02-26 19:20:29 163
原创 杭电OJ 1161(C++)
基本题。#include <iostream>#include <string>#include <cctype>using namespace std;int main(){ string s; while (getline(cin, s)) { int len = s.length(); for (int i = 0; i &...
2020-02-26 17:50:53 150
原创 杭电OJ 1160(C++)
基本动态规划题。#include <iostream>#include <algorithm>using namespace std;const int MAXN = 1005;struct mice //老鼠{ int w; //重量 int s; //速度 int cnt; //序号}m[MAXN];int dp[MAXN]; //dp[i...
2020-02-26 17:10:00 239
原创 杭电OJ 1159(C++)
基本动态规划题。设dp[i+1][j+1]表示截止s1[i], s2[j]为止的最大公共子序列长度。若s1[i] == s2[j],有 dp[i+1][j+1] = dp[i][j] + 1否则,有 dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])#include <iostream>#include <string>#...
2020-02-26 11:11:06 617
转载 杭电OJ 1158(C++)
基本动态规划题。#include <iostream>#include <algorithm>using namespace std;const int INF = 0x3f3f3f3f;int dp[12][1000]; //dp[i][j]表示目前有j名员工时,从第1个月到第i个月的最小花费int people[15]; //每月所需员工数int ...
2020-02-25 22:00:53 244
原创 杭电OJ 1157(C++)
基础题。全部排序后取中间的数即可。#include <iostream>#include <algorithm>using namespace std;const int MAXN = 10005;int arr[MAXN];int main(){ int N; while (cin >> N) { for (int i = 0; ...
2020-02-25 20:10:51 195
转载 杭电OJ 1156(C++)
#include <iostream>#include <algorithm>#include <vector>using namespace std;const int MAXN = 200002;int l[MAXN], r[MAXN]; //垂线左侧的点,垂线右侧的点int y[MAXN]; //y轴坐标int n, w;struct...
2020-02-25 19:19:02 150
转载 杭电OJ 1155(C++)
#include <iostream>#include <cmath>using namespace std;const double g = 9.81;int main(){ double k, l, s, w; while (cin >> k >> l >> s >> w) { ...
2020-02-25 11:40:07 156
转载 杭电OJ 1154(C++)
#include <iostream>#include <cmath>#include <algorithm>#include <iomanip>using namespace std;const double eps = 1e-8;const double INF = 1e20;const double PI = acos(-1....
2020-02-25 10:28:26 233
转载 杭电OJ 1153(C++)
#include <iostream>using namespace std;const int MAXN = 100005;int arr[100010];long long p;int main(){ while (cin >> p) { if (p == 0) break; if (p == 2) cout << "...
2020-02-24 18:10:04 97
原创 杭电OJ 1152(C++)
基础题。输入奇数个点,按输入顺序最中间的点为原点,分成四个象限。右上、左下象限中点的个数为A的得分,左上、右下象限中点的个数为B的得分,输出两者得分即可。#include <iostream>using namespace std;const int MAXN = 200005;int point[MAXN][2];int main(){ int n; whi...
2020-02-24 17:00:19 238
原创 杭电OJ 1151(C++)
本题与杭电OJ 1150解法基本相同,求二分图的最小边覆盖数。最小边覆盖 = 结点数 - 最大匹配数,使用匈牙利算法即可。#include <iostream>#include <cstring>using namespace std;const int MAXN = 1000;int edge[MAXN][MAXN]; //各结点之间的连接关系int us...
2020-02-23 17:40:08 160
原创 杭电OJ 1150(C++)
计算二分图的最小点覆盖,使用匈牙利算法,最小点覆盖数 = 最大匹配数。#include <iostream>using namespace std;const int MAXN = 105;//机器对照情况数组,结点匹配数组,结点访问数组int match[MAXN][MAXN], use[MAXN], vis[MAXN];int n, m, k;//查找从x出发的...
2020-02-23 12:30:05 200
原创 杭电OJ 1148(C++)
基础题。#include <iostream>#include <string>#include <cstring>#include <iomanip>using namespace std;const int MAXN = 105;int success[MAXN]; //每名选手胜利的次数int failure[MAXN]; ...
2020-02-22 14:40:10 171
原创 杭电OJ 1147(C++)
#include<iostream>using namespace std;const int MAXN = 100005;struct Segment //线段{ double x1, y1; double x2, y2;}s[MAXN];bool vis[MAXN]; //线段是否被压住//判断第i条线段和第j条线段是否相交bool intersectio...
2020-02-22 12:50:45 131
转载 杭电OJ 1046(C++)
同样的思路,使用队列和结构体会超时。#include <iostream>#include <string>#include <algorithm>using namespace std;const int N = 10005;int node_l[N], node_r[N];int id_l[N], id_r[N];int ans[N];...
2020-02-22 10:50:41 182
转载 杭电OJ 1145(C++)
#include <iostream>#include <iomanip>using namespace std;int n;double t;double dfs(int k, int money){ double m, tmp; if (k == n) { m = 0.5; tmp = 2 * money; if (t > m)...
2020-02-21 17:40:21 287
原创 杭电OJ 1144(C++)
基础题。将选择的课程存入数组中,查找每类课程中被选择的课程数量是否满足要求,所有种类的课程都满足要求时,输出"yes",否则输出"no"。#include <iostream>#include <string>#include <algorithm>using namespace std;const int MAXN = 105;int mai...
2020-02-21 17:17:07 154
转载 杭电OJ 1143(C++)
#include <iostream>using namespace std;int main(){ int n; int num[35] = { 0 }; num[0] = 1; num[2] = 3; int i = 4; while (i <= 30) { num[i] = 4 * num[i - 2] - num[i - 4]; i += ...
2020-02-21 13:30:17 151
原创 杭电OJ 1142(C++)
首先使用Dijkstra算法求出从家到达其余各点的最短路径,然后使用深搜求出从公司到家的符合要求的路径数。#include <iostream>using namespace std;const int INF = 0x3f3f3f3f;const int MAXN = 1005;int map[MAXN][MAXN]; //地图,map[i][j]的值为i点到j点的最...
2020-02-21 11:55:10 233
原创 杭电OJ 1141(C++)
求满足 n! < 2^bit 最大的n,其中 bit 为计算机芯片的位数。两边取对数 log(1) + log(2) +...+ log(n) < bit * log(2) 即可。#include <iostream>#include <cmath>using namespace std;int main(){ int y; while (c...
2020-02-21 10:00:19 193
QT、C++ 米其林自助点餐系统
2016-11-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人