- 博客(33)
- 收藏
- 关注
原创 洛谷P1063 能量项链
#include <iostream> using namespace std; int dp[101][101], num[101], n, Max; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> num[i]; for (int i = 2; i <= n; i++) //i是合并珠子的数量 f
2020-08-09 13:56:02 95
原创 洛谷P1016 旅行家的预算
#include <iostream> #include<cstdio> using namespace std; int main() { double p[8], d[8]; double d1, c, d2, x; int n; double min = 0; cin >> d1 >> c >> d2 >> p[0] >> n; d[0] = 0; d
2020-07-28 09:33:50 84
原创 洛谷P1006 传纸条
#include <iostream> using namespace std; int map[64][64], dp[64][64][64][64]; int main() { int m, n; cin >> m >> n; for (int i = 1; i <= m; i++) for (int j = 1; j <= n; j++) cin >> map[i][j];
2020-07-28 09:31:58 65
原创 洛谷P1004 方格取数
#include<iostream> using namespace std; int map[11][11], dp[11][11][11][11]; int main() { int n, x, y, m; cin >> n; while (1) { cin >> x >> y >> m; if (x == 0 && y == 0 && m == 0) break; map[x][y]
2020-07-28 09:30:44 51
原创 洛谷P1045 麦森数
#include <iostream> #include <cmath> using namespace std; int a[1000]; int main() { a[0] = 1; int p, num = 1; cin >> p; for (int i = 0; i < p; i++) { for (int j = 0; j < num; j++) a[j] = a[
2020-07-24 21:51:00 36
原创 洛谷P1195 口袋的天空
#include <iostream> #include <algorithm> using namespace std; struct Edge { int x, y, l; Edge(int x = 0, int y = 0, int l = 0) :x(x), y(y), l(l) {} }edge[200005]; int dis[200005]; bool cmp(Edge x, Edge y) { return x.l < y.l; }
2020-07-24 17:38:03 52
原创 1044 栈
卡特兰,Catalan #include <iostream> using namespace std; long int C(int x, int y) { long int t = 1; for (int i = 1; i <= y; i++) { t = t * (x - i + 1)/ i; } return t; } int main() { int n; cin >> n; cou
2020-07-23 10:16:32 45
原创 洛谷P1023 税收与补贴问题
#include <iostream> #include <cmath> int inf = 100000; double a[100000][2]; using namespace std; int main() { int n, m = 1; cin >> n; cin >> a[0][0] >> a[0][1]; while (1) { double t0, t1;
2020-07-22 21:15:08 49
原创 洛谷P1002 过河卒
#include <iostream> using namespace std; long long map[24][24]; int main() { int n, m, a, b; cin >> n >> m >> a >> b; map[a][b] = -1; if (a - 2 >= 0 && b - 1 >= 0) map[a - 2][b - 1] = -
2020-07-22 17:10:10 39
原创 HDU二叉搜索树
#include <iostream> #include <cstring> using namespace std; char a[16]; struct node { int v; node* l; node* r; node(int v = 0, node* l = NULL, node* r = NULL) { this->v = v; this->l = l; this
2020-07-21 21:48:19 46
原创 洛谷 导弹拦截
复杂度n² #include <iostream> using namespace std; int a[100001], dp[100001]; int main() { int n = 0, max = 0; while (cin >> a[n]) n++; for (int i = 0; i < n; i++) { if (i == 0) dp[i] = 1; else
2020-07-20 22:28:29 77
原创 HDU1159 最长公共子序列
#include <iostream> using namespace std; char s1[1024], s2[1024]; int dp[1024][1024]; int main() { while (cin >> s1 >> s2) { int len1 = strlen(s1), len2 = strlen(s2); for (int i = 1; i <= len1; i++)
2020-07-20 22:04:29 50
原创 洛谷P1111 修复公路
#include <iostream> #include <algorithm> using namespace std; int s[2000]; struct Map { int x, y, t; }map[100000]; bool cmp(Map& x, Map& y) { return x.t < y.t; } int find(int x) { if (s[x] == x) return x; s[x] = fin
2020-07-16 20:02:39 38
原创 洛谷P1364 医院设置
#include <iostream> using namespace std; int dis[200][200]; int s[200], l[200], r[200]; int inf = 9999999; int main() { int n, w, u, v, min = inf; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++)
2020-07-15 23:54:31 250
原创 洛谷P3367 【模板】并查集
#include <iostream> using namespace std; int s[1000001]; int find(int x) { if (x == s[x]) return x; s[x] = find(s[x]); return s[x]; } int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++)
2020-07-15 11:14:40 41
原创 HDU3635 Dragon Balls
#pragma warning(disable:4996) #include <cstdio> #include <iostream> using namespace std; int s[1204]; int book[1024][2]; int find(int x) { if (s[x] == x) return x; else { s[x] = find(s[x]); book[s[x]][1] += book[x][1]
2020-07-14 22:36:24 87
原创 HDU 1710 Binary Tree Traversals(给出前序中序输出后序)
#pragma warning(disable:4996) #include <iostream> #include <cstdio> using namespace std; struct node { node* r, * l; int v; node(int v = 0, node* r = NULL, node* l = NULL): v(v), l(l), r(r) {}; }; int xian[1024]; int zhong[1024];
2020-07-14 11:04:20 53
原创 洛谷P1305 新二叉树
#include <iostream> #include <queue> using namespace std; struct Node { char v; Node* l, * r; Node(char v = '\0', Node* l = NULL, Node* r = NULL) { this->v = v; this->l = l; this->r = r; }
2020-07-10 00:13:19 39
原创 P1102 A-B 数对
#include <iostream> #include <algorithm> using namespace std; int a[2000001]; int main() { long n, c, num = 0; cin >> n >> c; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for
2020-07-08 21:58:46 62
原创 P2240 部分背包问题
#include #include #include using namespace std; struct Gold{ double m; double v; double d; }gold[101]; int book[101]; bool cmp(Gold x, Gold y) { return x.d > y.d; } int main() { int n, t; cin >> n >> t; double V = 0; for (int i = 0; i <
2020-07-08 21:36:42 129
原创 洛谷P1757 通天之分组背包
#include <iostream> using namespace std; struct goods { int wei; int val; }goods[1024]; int gro[1024][1024]; int dp[1024][1024]; int main() { int n, m; cin >> m >> n; int max = 0; for (int i = 1; i <= n; i++)
2020-07-07 16:30:08 101
原创 HDU2602 Bone Collector
0/1背包 #include <iostream> using namespace std; int dp[1024][1024]; int val[1024]; int vol[1024]; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n, V; cin >> n >> V; for
2020-07-07 16:28:08 37
原创 HDU2121 Today
#include <iostream> #include <map> #include <string> using namespace std; int n; int inf = 999999999; int bus[201][201]; int book[151]; int main() { while (cin >> n && n != -1) { map<string, int> pla
2020-07-05 01:30:15 60
原创 洛谷P1033 自由落体
#include <iostream> #include <cmath> using namespace std; double H, S1, V, L, K, n; double e = 0.0001; int num = 0; int main() { cin >> H >> S1 >> V >> L >> K >> n; double t1 = sqrt(H / 5), t2 = s
2020-07-03 17:29:48 91
原创 HDU1272 并查集
#include <iostream> int vid[100001]; int m, n; bool flag = false; using namespace std; int find(int root) { if (vid[root] != root) vid[root]=find(vid[root]); else return vid[root]; } int main() { while (cin >> m >> n)
2020-07-02 22:12:40 58
原创 hdu2544
Floyd-Warshall算法 #include <iostream> using namespace std; int map[101][101]; int n, m; int inf = 999999999; int main() { int a, b, c; while (1) { cin >> n >> m; if (n == 0 && m == 0) return 0; for(int i = 1; i <= n;
2020-07-02 14:33:49 53
原创 洛谷P1098 字符串的展开
#include <iostream> #include <cstring> using namespace std; char a[101], b[10001]; int p1, p2, p3; int main() { cin >> p1 >> p2 >> p3; cin >> a; int len = strlen(a); int j = 0; for (int i = 0; i < len; i++) {
2020-07-01 22:09:22 74
原创 洛谷P1154 奶牛分厩
暴力枚举,超时80分 #include <iostream> using namespace std; int a[5001], n; int main() { int i = 1, j, t; while (1) { for (j = 0; j < n; j++) { t = a[j] % i; num[t]++; if (num[t] >
2020-07-01 19:03:42 94
原创 HDU1237 简单计算器
写的有点啰嗦了 #include <iostream> #include <cstdio> using namespace std; char a[201]; int len; int main() { while (1) { gets_s(a); len = strlen(a); if (a[0] == '0' && len == 1) break; double t1 = 0,
2020-06-30 23:13:58 76
原创 快速排序
#include <iostream> using namespace std; int n, a[1000001]; void sore(int* a, int size) { if (size == 1 || size == 0) return; int t = a[0], x = 0; int s = 0, l = size - 1; while (s < l) { while (t <= a[l] &&a
2020-06-30 18:54:20 43
原创 洛谷P2615 神奇的幻方
#include<iostream> using namespace std; int m[40][40], n; int main() { cin >> n; int x = n / 2 + 1, y = 1; for (int i = 1; i <= n * n; i++) { m[x][y] = i; x++; y--; if (x > n&& y <= 0) { x--; y += 2; }
2020-06-30 00:07:08 65
原创 洛谷P1303 A*B Problem
#include<iostream> #include<cstring> using namespace std; char A[20001], B[20001]; int a[20001], b[20001], c[20001]; int main() { cin >> A >> B; if (A[0] == '0' || B[0] == '0') { cout << 0; return
2020-06-29 23:32:32 55
原创 洛谷P1480 A/B Problem
高精度除以单精度 #include<iostream> #include<cstdio> using namespace std; char A[1001]; int a[50001], b, c[50001]; int main() { int len = 0, x = 0; char t = getchar(); while (t >= '0' && t <= '9') { a[len] = t -
2020-06-29 23:25:46 172
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人