
枚举
西瓜不甜不甜不甜
这个作者很懒,什么都没留下…
展开
-
【POJ】2718 - Smallest Difference
http://poj.org/problem?id=2718给出最多10个数字,划分为两个整数,求差值最小的值(除非只有一位数,否则不允许出现先导0)若有n个数,必然有一个整数长n/2,另一个长n-n/2。利用next_permutation()函数枚举数字的每个排列#include <iostream>#include <cstdio>#include <cstring> #include原创 2017-08-17 15:53:30 · 257 阅读 · 0 评论 -
【POJ】3187 - Backward Digit Sums
http://poj.org/problem?id=3187输入n,sum,按杨辉三角的规则,求1~n的数。全排列#include <iostream>#include <cstdio>#include <cstring> #include <algorithm>using namespace std;int n,sum;int a[20],b[20];int main(){ whi原创 2017-08-17 16:43:21 · 203 阅读 · 0 评论 -
【POJ】3050 - Hopscotch
http://poj.org/problem?id=3050在5 * 5的方格里跳房子,起点是任意位置。将跳过的数连起来组成一个5位数(前导零可能),问一共能组成多少个数字?#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;bool used[1000000];原创 2017-08-17 16:46:22 · 212 阅读 · 0 评论 -
Codeforces 940 A. Points on the line 暴力
http://codeforces.com/contest/940/problem/A直线上有n个点,去掉最少的点,使最远两点距离不超过d。暴力#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>using namespace std;#...原创 2018-03-04 19:01:03 · 199 阅读 · 0 评论 -
蓝桥 历届试题 带分数 全排列
http://lx.lanqiao.cn/problem.page?gpid=T26#include <bits/stdc++.h>using namespace std;const int maxn=1000000+5;const int INF=0x3f3f3f3f;long k[maxn];int num[11];int n;int ans;void g...原创 2018-03-13 19:42:09 · 268 阅读 · 0 评论 -
算法提高 排列数 全排列
http://lx.lanqiao.cn/problem.page?gpid=T352注意题目要求,是按照大小顺序的,所以全排列后,再排序。#include <bits/stdc++.h>using namespace std;const int maxn=105;const int INF=0x3f3f3f3f;int n;int a[11];long lon...原创 2018-03-13 21:52:04 · 390 阅读 · 0 评论