![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
欧拉计划
霍传飞
hello world!
展开
-
图存储与最短路径2
最短路径:1,贝尔曼·富德-bellman·ford:单元最短路,暴力遍历每条边去更新答案。不能有负环根据s已知的答案去更新e的答案:s-v->e: ans[e] = min(ans[e], ans[s]+v)复杂度O(nxm) n:节点数 m:边数#include <iostream>#include <cstring>#include <cstdio>using namespace std;struct edge { int s,原创 2021-03-06 16:55:13 · 148 阅读 · 1 评论 -
图存储与最短路径1
图的概念:点和边组成的集合边的方向:有向边:有向图;无向边:无向图;边的权值:可以为负数和正数点的度:度 = 出度 + 入度图的存储:邻间矩阵 => 二维数组原创 2021-02-28 23:03:05 · 145 阅读 · 0 评论 -
Problem 18 数塔最大路径和
7595 6417 47 8218 35 87 1020 04 82 47 6519 01 23 75 03 3488 02 77 73 07 63 6799 65 04 28 06 16 70 9241 41 26 56 83 40 80 70 3341 48 72 33 47 32 37 16 94 2953 71 44 65 25 43 91 52 97 51 1470 11 33 28 77 73 17 78 39 68 17 5791 71 52 38 17 14 91 4原创 2020-12-30 15:10:43 · 171 阅读 · 0 评论 -
Problem 15 网格路径
对于20x20的网格,从左上角到右下角的所有路径条数;典型的递推问题。1 DP解法:#include <iostream>using namespace std;long long dp[25][25];int main() { for (int i = 1; i <= 21; i++) { for (int j = 1; j <= 21; j++) { if (i == 1 && j == 1) { dp[i][j] = 1;原创 2020-12-30 14:16:03 · 188 阅读 · 0 评论 -
大整数减法
#include <iostream>#include <cstring>using namespace std;char num1[1005], num2[1005];int n1[1005], n2[1005], ans[1005];int main() { cin >> num1 >> num2; n1[0] = strlen(num1); n2[0] = strlen(num2) - 1; ans[0] = max(n1[0],原创 2020-12-30 13:13:07 · 112 阅读 · 0 评论 -
大整数乘法
#include <iostream>#include <cstring>using namespace std;char num1[1005], num2[1005];int n1[1005], n2[1005], ans[1005];int main() { cin >> num1 >> num2; n1[0] = strlen(num1); n2[0] = strlen(num2); ans[0] = n1[0] + n2[0] -原创 2020-12-29 23:11:27 · 104 阅读 · 0 评论 -
Problem 25 1000位斐波那契数(大整数加法)
斐波那契数列是按如下递归定义的数列:F1 = 1 F2 = 1 Fn = Fn-1 + Fn-2在斐波那契数列中,第一个包含1000位数字的是第几项?#include <iostream>using namespace std;int func(int *n1, int *n2) { n2[0] = n1[0]; for (int i = 1; i <= n2[0]; i++) { n2[i] += n1[i]; if (n2[i] > 9) { n原创 2020-12-29 15:47:13 · 244 阅读 · 1 评论 -
Problem 2 偶斐波那契数
斐波那契数列中的每一项都是前两项的和。由和开始生成的斐波那契数列的前项为:1, 2, 3, 5, 8, 13, 21, 34, 55, 89,…考虑该斐波那契数列中不超过四百万的项,求其中为偶数的项之和。#include <iostream>using namespace std;#if 0int num[1000000];int main() { long long ans = 2; num[1] = 1, num[2] = 2; for (int i = 3; 1; i+原创 2020-12-29 15:28:09 · 150 阅读 · 0 评论 -
Problem 13 大和
1,输入数字,并将数字倒序存储2,对齐后相加3,处理进位4,输出答案#include <iostream>#include <cstring>using namespace std;char num1[1005], num2[1005];int n1[1005], n2[1005], ans[1005];int main() { cin >> num1 >> num2; n1[0] = strlen(num1); n2[0] = s原创 2020-12-29 15:17:40 · 86 阅读 · 0 评论