![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
WindSearcher
打造自己的梦想,否则就被雇佣打造他人的梦想!
展开
-
Fence Repair
#include<iostream>#include<algorithm>using namespace std;typedef long long ll;#define MAXSIZE 100int n , l[MAXSIZE];void solve(){ ll ans = 0; while(n > 1) { sort(l,l+n);...原创 2018-07-11 09:31:52 · 108 阅读 · 0 评论 -
c++高精度模板
#include<iostream> #include<cstring>#include<string> using namespace std; int main() { char str1[10000] = {'\0'},str2[10000] = {'\0'}; int a[10000],b[10000],c[10000];...原创 2019-08-24 10:14:36 · 158 阅读 · 0 评论 -
回顾蓝桥杯真题
1.方程整数解方程: a^2 + b^2 + c^2 = 1000(或参见【图1.jpg】)这个方程有整数解吗?有:a,b,c=6,8,30 就是一组解。你能算出另一组合适的解吗?请填写该解中最小的数字。注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。思路:暴力枚举法思考:如果不是为1000,而是比较大的数,此时暴力就会超时,那么又该何解?可以用二分,对...原创 2019-02-25 14:26:10 · 220 阅读 · 0 评论 -
康托展开和逆康托展开
简述 康托展开是一个全排列到一个自然数的双射,常用于构建hash表时的空间压缩。设有n个数(1,2,3,4,…,n),可以有组成不同(n!种)的排列组合,康托展开表示的就是是当前排列组合在n个不同元素的全排列中的名次。原理X=a[n]*(n-1)!+a[n-1]*(n-2)!+...+a[i]*(i-1)!+...+a[1]*0!其中, a[i]为整数,并且0 <= a[...原创 2019-01-20 18:47:27 · 214 阅读 · 0 评论 -
G - Fibonacci Again
There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).InputInput consists of a sequence of lines, each containing an integer n. (n < 1,000,000).Ou...原创 2018-11-18 11:06:20 · 316 阅读 · 0 评论 -
B - Least Common Multiple
The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105. InputI...原创 2018-11-18 10:53:12 · 166 阅读 · 0 评论 -
K - 排序
输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整数就是由若干个‘0’组成的,这时这个整数就是0)。你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出。 Input输入包含多组测试用例,每组输入数据只有一行数字(数字之间没有空格),这行数字的长度不大于1000。 输...原创 2018-11-18 10:46:28 · 1432 阅读 · 0 评论 -
1014福尔摩斯的约会
#include<iostream>#include<string>#include<cctype>#include<cstdio>using namespace std;char s[7][4] = {"MON","TUE","WED","THU","FRI","SAT",&q原创 2018-07-06 11:01:44 · 168 阅读 · 0 评论 -
hdu 1016 - Prime Ring Problem
此题类似全排列的题,把1-n个数的全排列输出,但这道题需要去剪枝,如何来剪枝,我是按顺时针来剪枝,每次只需和下一位数字的和验证是否为素数,但是最后一个是例外,它需要和前一位数字,第一位数字分别相加来验证是否正确AC代码如下:#include<stdio.h>int a[22];int book[22];int n;int ans = 0;//检查是否为素数bool check(int ...原创 2018-07-12 09:26:20 · 117 阅读 · 0 评论 -
可任意求某个日期是星期几
模板题:#include <iostream>#include <string>using namespace std;// 1 1 1 Mondayint whatday(int y, int m, int d) { // 返回正确的星期。用 0 - 6 表示 星期 1 - 7 if(m==1||m==2) { ...原创 2019-09-14 09:42:54 · 132 阅读 · 0 评论