
算法
ZHappyDragon
这个作者很懒,什么都没留下…
展开
-
AcWing 91. 最短Hamilton路径
状压dp 二进制给定一张 n 个点的带权无向图,点从 0∼n−1 标号,求起点 0 到终点 n−1 的最短 Hamilton 路径。Hamilton 路径的定义是从 0 到 n−1 不重不漏地经过每个点恰好一次。输入格式第一行输入整数 n。接下来 n 行每行 n 个整数,其中第 i 行第 j 个整数表示点 i 到 j 的距离(记为 a[i,j])。对于任意的 x,y,z,数据保证 a[x,x]=0,a[x,y]=a[y,x] 并且 a[x,y]+a[y,z]≥a[x,z]。输出格式输出.原创 2021-03-07 14:07:51 · 228 阅读 · 0 评论 -
64位整数乘法
求 a 乘 b 对 p 取模的值。输入格式第一行输入整数a,第二行输入整数b,第三行输入整数p。输出格式输出一个整数,表示a*b mod p的值。数据范围1≤a,b,p≤1018输入样例:345输出样例:2代码//// Created by Administrator on 2021/1/10.//#include <stdio.h>#define ll long longint main(){ ll a,b,p; sca原创 2021-01-10 14:10:10 · 178 阅读 · 0 评论 -
a^b 快速幂两种方式
求 a 的 b 次方对 p 取模的值。输入格式三个整数 a,b,p ,在同一行用空格隔开。输出格式输出一个整数,表示a^b mod p的值。数据范围0≤a,b,p≤109数据保证 p≠0输入样例:3 2 7输出样例:2#include <stdio.h>long long a,b,p,ans=0,k[107]={0},t=0;long long md(int c) //法一{ if (c==0) return 1%p; if (c==1) retur原创 2020-09-05 16:03:22 · 280 阅读 · 1 评论 -
640: Binary search
题目描述A binary search algorithm (or binary chop) is a technique for finding a particular value in a sorted list. It makes progressively better guesses, and closes in on the sought value, by comparing a...原创 2020-04-25 18:59:07 · 460 阅读 · 0 评论 -
536: The Josephus Problem
题目描述The problem is named after Flavius Josephus, a Jewish historian who participated in and chronicled the Jewish revolt of 66-70C.E. against the Romans. Josephus, as a general, managed to hold the f...原创 2020-04-25 18:28:48 · 714 阅读 · 0 评论 -
480: Locker doors
题目描述There are n lockers in a hallway numbered sequentially from 1 to n. Initially, all the locker doors are closed. You make n passes by the lockers, each time starting with locker #1. On the ith pas...原创 2020-04-25 17:40:36 · 926 阅读 · 0 评论 -
swustoj254: 翻煎饼
题目描述麦兜最喜欢的食物是煎饼,每次在街上看到煎饼摊的时候都会在那里停留几分钟。最吸引麦兜还是煎饼师傅那一手熟练的翻煎饼的技术,一堆煎饼在那里,师傅只需要用铲子翻几下,就让煎饼整齐的叠在了一起。 这天,为了庆祝麦兜被保送上研究生,他从煎饼师傅那里买回来一些煎饼请客。但是麦兜买回的煎饼大小不一,麦兜太想吃煎饼了,他想吃这些煎饼中最大的那个。麦兜还知道同学们也很喜欢煎饼,为了表示他的诚意,他想让同学...原创 2020-04-25 17:30:48 · 1672 阅读 · 0 评论 -
swustoj哈夫曼译码
题目描述通常要求根据给定的编码本对密文进行解码。现已给定相应字符的哈夫曼编码,要求根据编码对密文进行解码。输入根据哈夫曼树编码表,针对字符串做好的编码结果。输出对每一行需要解码的串,进行解码,并输出解码后的结果。样例输入000100011011101110样例输出aabccconst int maxvalue=100;const int maxbit=100;const i...原创 2019-05-03 22:27:32 · 1157 阅读 · 0 评论 -
99: Euclid's Game
题目描述Starts with two unequal positive numbers (M,N and M>N) on the board. Two players move in turn. On each move, a player has to write on the board a positive number equal to the difference of two...原创 2020-04-25 16:50:54 · 541 阅读 · 0 评论