- 博客(9)
- 收藏
- 关注
原创 直线
#include<iostream>#include<set>using namespace std;struct Line { int a, b, c; friend operator< (Line A, Line B) { if(A.a != B.a) return A.a > B.a; if(A.b != B.b) return A.b > B.b; return A.c > B.c; }} line;int g.
2021-04-24 16:20:34
145
原创 左子右兄
本题给定一个庞大家族的家谱,要请你给出最小一辈的名单。需要注意的是,家族成员的输入方式,是按照“Left-child Right-sibling”(左儿子 右兄弟)的格式【敲黑板】sibling的意思是兄弟/姐妹,是亲兄弟,不是“表兄弟”!2019年春季PAT中不认识单词sibling的孩纸请牢记……注:本题是在浙江大学陈越老师的GPLT-2018决赛L2-2题目“小字辈”题意基础上改编而成。输入格式:输入在第一行给出家族人口总数 N(不超过 100 000 的正整数) —— 简单起见,我们把家族
2020-10-24 18:47:02
278
原创 分治(快速幂)
给定三个整数a(a>=0),n(n>=0),p(p>0)。 求解 ans=(a0+a1+a2+a3+…+a^n)mod p1≤T≤1e50≤a≤1e90≤n≤1e180<p≤2e9#include<iostream>#include<cstdio>using namespace std;long long Pow(int x, long long y, int p) { if(y == 0) return 1%p; else if(y
2020-10-21 11:50:31
135
原创 1-1统计数字问题
题目给定整数n,算出[1,n]所有数字(0-9)出现个数#include<iostream>#include<cmath>using namespace std;const int MAXN = 10;int f[MAXN];void init() { for(int i = 1; i < MAXN; i++) { f[i] = i * pow(10, i-1); }}void print(int *ans) { for(int i = 0; i &
2020-10-01 10:15:43
183
原创 最大间隙问题
问题表述求若干点中间隔最大的两个相邻点#include<iostream>#include<algorithm>#include<cstdlib>#include<ctime>using namespace std;const int MAXN = 2;void print(int *a){ for(int i = 0;i < MAXN;i++) { cout << a[i] << " "; }}i
2020-09-30 23:39:00
174
原创 最近点对问题(一维)
#include<iostream>#include<cstdlib>#include<ctime>#include<algorithm>using namespace std;const int MAXN = 5;const int inf = 1e9;void swap(int *x, int *y){ int t = *x; *x = *y; *y = t;}int partition(int *a, int p, int q)
2020-09-30 10:35:10
1596
原创 试题 历届试题 九宫重排(双向广搜)
问题描述 如下面第一个图的九宫格中,放着 1~8 的数字卡片,还有一个格子空着。与空格子相邻的格子中的卡片可以移动到空格中。经过若干次移动,可以形成第二个图所示的局面。我们把第一个图的局面记为:12345678. 把第二个图的局面记为:123.46758 显然是按从上到下,从左到右的顺序记录数字,空格记为句点。 本题目的任务是已知九宫的初态和终态,求最少经过多少步的移动可以到达。如果无论多少步都无法到达,则输出-1。输入格式 输入第一行包含九宫的初态,第二行包含九宫的终态。输出
2020-09-29 22:12:45
186
原创 快速排序(无重复元素)
#include<iostream>#include<cstdlib>#include<ctime>using namespace std;void swap(int *a, int *b){ int t = *a; *a = *b; *b = t; } int partition(int *a, int p, int q){ int pivot = a[p]; int i = p; for(int j = p+1;j <= q;j++)
2020-09-29 18:05:05
193
原创 试题 历届试题 青蛙跳杯子
#include<iostream>#include<queue>#include<map>using namespace std;string source;string result;int Next[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};map<string, bool> vis; map<string, int> level;string swap(string str, i
2020-09-28 21:16:47
112
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人