- 博客(10)
- 收藏
- 关注
原创 常用算法知识点
判定质数bool is_prime(int x){ if (x < 2) return false; for (int i = 2; i <= x / i; i ++ ) if (x % i == 0) return false; return true;}
2021-08-07 23:52:30
189
原创 Buying Shovels
Buying ShovelsPolycarp wants to buy exactly nn shovels. The shop sells packages with shovels. The store has kk types of packages: the package of the ii-th type consists of exactly ii shovels (1≤i≤k1≤i≤k). The store has an infinite number of packages of ea
2021-07-19 22:28:32
165
原创 食物链
食物链Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句话有的是真的,有的是假的。当一句话满足下列三条之一时,这句话就是假话,否则就是真话
2021-04-10 14:41:51
142
原创 Expedition
POJ 2413 Expedition用G++提交可以通过代码如下:#include<iostream>#include<algorithm>#include<queue>#include<vector>#include<string>#include<utility>using namespace std;typedef pair<int,int> PII;const int N=10010;in
2021-04-09 17:11:36
190
原创 编辑距离
编辑距离题目描述设A和B是两个字符串。我们要用最少的字符操作次数,将字符串A转换为字符串B。这里所说的字符操作共有三种:1、删除一个字符;2、插入一个字符;3、将一个字符改为另一个字符;输入格式第一行为字符串A;第二行为字符串B;字符串A和B的长度均小于2000。输出格式只有一个正整数,为最少字符操作次数。输入输出样例输入sfdqxbwgfdgw输出4代码如下#include<bits/stdc++.h>using namespace std;cons
2021-03-14 11:18:41
270
原创 全排列问题
全排列问题题目描述输出自然数 11 到 nn 所有不重复的排列,即 nn 的全排列,要求所产生的任一数字序列中不允许出现重复的数字。输入格式一个整数 nn。输出格式由 1∼n 组成的所有不重复的数字序列,每行一个序列,每个数字保留 55 个场宽。输入输出样例输入 13输出 1 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1说明/提示1&l
2021-02-26 16:41:11
1083
原创 A == B?
A == B ?Problem DescriptionGive you two numbers A and B, if A is equal to B, you should print “YES”, or print “NO”.Inputeach test case contains two numbers A and B.Outputfor each case, if A is equal to B, you should print “YES”, or print “NO”.Sample
2020-12-17 21:25:48
690
1
原创 高精度加法
C++ 高精度加法资源限制时间限制:1.0s 内存限制:256.0MB问题描述 高精度加法输入格式两行,表示两个非负整数a、b。输出格式一行表示a+b的值。样例输入112233445566778899998877665544332211样例输出1111111111111111110代码如下#include<iostream>#include<string>#include<algorithm>using namespace
2020-09-21 21:16:02
1106
原创 高精度乘法
C++ 高精度乘法输入格式: 第一行输入一个整数a 第一行输入一个整数b输出格式: 一个表示a*b的整数#include<iostream>#include<string.h>using namespace std;int main(){ char a[300]; char b[300]; cin>>a>>b; int la=strlen(a); int lb=strlen(b); int sa[300]={0}; int
2020-08-11 17:57:18
205
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅