一点算法
市井烟火气
sdnu
展开
-
单个html文件调用highlight.js
单个文件调用highlight.js原创 2022-09-08 12:36:23 · 224 阅读 · 0 评论 -
冒泡排序
#include <stdio.h>#include <iostream>using namespace std;void Sort(int * a, int len){ for(int i = len - 1; i >= 1; --i) for(int j = 0; j <= i - 1; ++j) i...原创 2019-09-29 19:37:50 · 92 阅读 · 0 评论 -
1331.Kick Veges' Ass SDNUOJ1331(简单二分)(2018总结赛)
DescriptionThere are n veges stand in line, Albert_s plan to punish them since they are too weak. The picture following below shows one of the veges waiting to be kicked.Now Albert_s plan to kick al...原创 2018-12-25 21:25:28 · 249 阅读 · 0 评论 -
最小公倍数lcm与最大公因数gcd
#include &lt;iostream&gt;using namespace std;int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);}int lcm(int a,int b){ return(a / gcd(a,b) * b);}int main(){ int a, b; ...原创 2018-12-30 12:08:06 · 219 阅读 · 0 评论 -
快速幂(取模)
求 a ^ b % c#include<iostream>using namespace std;int ksm(long long a, long long b, long long c){ int ans = 1; a = a % c;///将a控制在c以内 while(b) { if(b & 1) ...原创 2018-12-30 10:06:36 · 139 阅读 · 0 评论 -
GCD最大公因数
long long gcd(long long a, long long b){ return b == 0 ? a : gcd(b, a % b);}原创 2018-12-28 16:21:52 · 323 阅读 · 0 评论 -
1086.迷宫问题
Description定义一个二维数组:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 ...原创 2018-12-22 16:09:03 · 288 阅读 · 0 评论 -
1220.Look for homework SDNUOJ1220
Description(the picture has no relation with this problem…I just want to add a picture. emmm…)Super scholar robs the all homework of others. The monitor decides to combat with the super scholar so a...原创 2018-12-22 12:18:20 · 189 阅读 · 0 评论 -
LIS(正向)输出路径(n * logn版)
原作者:Lj_三日小先森原文:https://blog.csdn.net/Lj_victor/article/details/81603657我复制了其代码,并略加改动/// -7 10 9 2 3 8 8 1#include<cstdio>#include<cmath>#include<cstring>#include<algo...原创 2018-12-15 14:58:09 · 383 阅读 · 0 评论 -
LIS (逆向)输出路径(n * n版) 结合SDNUOJ1292(新手看过来)
#include &amp;lt;cstdio&amp;gt;#include &amp;lt;cmath&amp;gt;#include &amp;lt;algorithm&amp;gt;#include &amp;lt;cstring&amp;gt;#include &amp;lt;iostream&amp;gt;#defin原创 2018-12-15 10:04:57 · 179 阅读 · 0 评论 -
LIS最长不下降(上升或持平)子序列 n * logn版
输入多个数字,直到EOF,计算其LIS#include &lt;cstdio&gt;#include &lt;iostream&gt;#include &lt;cmath&gt;#include &lt;algorithm&gt;#include &lt;cstring&gt;using namespace std;i原创 2018-12-14 20:23:38 · 180 阅读 · 0 评论 -
LDS最长不上升(下降或持平)子序列 n * logn版(SDNUOJ1292圣诞老人)
输入多个数字,直到EOF,计算其LDS#include &amp;lt;cstdio&amp;gt;#include &amp;lt;iostream&amp;gt;#include &amp;lt;cmath&amp;gt;#include &amp;lt;algorithm&amp;gt;#include &amp;lt;cstring&am原创 2018-12-14 20:21:16 · 151 阅读 · 0 评论 -
查找质因数(埃氏筛打表,判断因子)
#include<cstdio>#include<iostream>#include<string.h>#include<algorithm>using namespace std;const int maxn=1e6; ///范围int tot; ...原创 2018-12-02 16:00:40 · 690 阅读 · 0 评论 -
线性筛
线性筛查找素数#include&amp;lt;bits/stdc++.h&amp;gt;using namespace std;#define maxn 1000005bool vis[maxn];int p[maxn];int tot;//线性筛:每个合数仅被它的最小质因子筛过,且为一次//线性筛找n以内的素数void prime(int n){tot=0;memset(vis,1,si...原创 2018-11-14 20:44:56 · 139 阅读 · 0 评论