随笔分类 - 蓝桥杯
摘要:开数组要注意位置!!!因为评测环境的不同可能会出错!!! 在函数中定义的变量,在栈上创建,全局定义的变量,在数据段上创建。由于你的数组太大,会造成栈溢出,使得程序错误。堆栈据说是2M大小,而数据段要大很多,具体多大好像与系统环境相关。 记录S=>T路径数ans 给所以经过的点计数,存储在cnt[]中
阅读全文
摘要:翻日历即可,不需要想太复杂,第一次提交未考虑20世纪的答案了,87分,我服了 以下是100分代码 1 #include <set> 2 #include <cstdio> 3 #include <iostream> 4 using namespace std; 5 bool check(int ye
阅读全文
摘要:有一说一,check不好想 思路解析,from 这里 1 #include <set> 2 #include <cstdio> 3 #include <iostream> 4 using namespace std; 5 multiset<pair<int,int> >A; 6 const int
阅读全文
摘要:不知道区间更改怎么搞... 1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 typedef long long ll; 5 const int MAXN=1e5+10; 6 struct node{ll sum,a
阅读全文
摘要:别想什么循环节优化了,模拟不香吗? 1 #include <iostream> 2 using namespace std; 3 int a,b,n; 4 int main() { 5 cin>>a>>b>>n,a=a%b; 6 for(int i=0;i<n+2;i++,a=a*10%b) 7 i
阅读全文
摘要:注意别把数组开小了! 1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 const int maxn=1000000+10; 5 int fa[maxn],t[maxn],m,n,k,ans; 6 int find(
阅读全文
摘要:着实精妙! 女少口阿!女少口阿! 1 #include <iostream> 2 #define N 100//思路:可以抽象为无向图染色问题。相邻顶点不能染相同颜色,问至少要用多少种颜色。 3 using namespace std; 4 int n,m,a,b,ans,next[N][N],ma
阅读全文
摘要:无非是计算s1个+a和s2个-b的排列数(s1+s2=(1+n)*n/2=sum) 比如在第一位+a的话,之后的每个数都累积了+a,相当于当前排上了n-1个+a 所以,可以设状态f[i][j]为:用数字1~i(每个只能选一次)可以组成和为j的方案数 实际上就是一个容量=价值的01背包 对于s1(0~
阅读全文
摘要:T1.求a^2+b^2+c^2=1000正整数解 1 #include <cstdio> 2 int main(){ 3 for(int a=1;;a++) 4 for(int b=a;b<=33;b++) 5 for(int c=b;c<=33;c++) 6 if(a*a+b*b+c*c==100
阅读全文
摘要:首先一秒钟想到的斐波拉契模板,矩阵快速幂加速 之前有过类似博客,这里不赘述原理。 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 using namespace std; 5 typedef long long ll;
阅读全文
摘要:一开始想的是dp四维状态都设好了,然后写起来贼恶心 然后改搜索,四类分支都想好了,但是复杂度又不对? 放弃后,看题解,艹,还真是两者结合起来,记忆化搜索。 好吧,不愧是你,蓝桥杯,这么喜欢暴力算法! PS: 对于一个搜索状态,其返回值可能为0,所以数组初值要赋为-1 1 #include <cstd
阅读全文
摘要:蚂蚁出界了我没有标记居然可以过样例?还有25分?GG 补上标记就A了,2014真题真的水,蓝桥杯啊蓝桥杯!! 1 #include <cmath> 2 #include <cstdio> 3 #include <iostream> 4 #include <algorithm> 5 using nam
阅读全文
摘要:check全排列,保留字典数最小解 answer: 2342A3A4 1 #include <bits/stdc++.h> 2 using namespace std; 3 char c[8]={'A','A','2','2','3','3','4','4'}; 4 char r[8],ans[8]
阅读全文
摘要:网络上流传的版本是错的,还有那么多人转载,真的是醉了 代码的思路是比较a数组,用b数据记录下标,故答案为(a[b[k1]]>a[b[k2]]) 1 #include<bits/stdc++.h> 2 //重新决出k号位置,v为已输出值 3 void pk(int* a, int* b, int n,
阅读全文
摘要:四个不同数码凑一个乘法算式,结果恰好仍然只含这四个数码 1 #include <bits/stdc++.h> 2 using namespace std; 3 int ij[10],vis[10]; 4 bool check(int i,int j){ 5 int k=i*j,cnt=0; 6 me
阅读全文
摘要:我就笑笑,这不是手玩dp吗?! 1 #include <bits/stdc++.h> 2 using namespace std; 3 int f[20]; 4 int main(){ 5 f[0]=2; 6 for(int i=1;i<20;i++) 7 f[i]=f[i-1]*2-1; 8 co
阅读全文
摘要:1 #include <bits/stdc++.h> 2 using namespace std; 3 int main(){//a*b=6*(a+b) abs(a-b)<8 4 for(int a=1;a<=18;a++) 5 for(int b=a+1;b<a+8;b++) 6 if(a*b==
阅读全文
摘要:最坑的一点是没有数据范围,但是就蓝桥杯的德性,int就够了然后数组尽可能开大一点 O(n)算法要自信,嗯嗯嗯! 一次AC,没什么好说的,上代码: 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 const int
阅读全文
摘要:如题: 将矩阵剪成相连的两个联通块,可以有环,使得两部分权值和相等 数据范围矩阵<10x10,权值和<1000000 我寻思着觉得复杂度不对啊?自己卡个数据都会T,题目的数据太水了 dfs是错误写法,对于不满足从(1,1)开始的一笔完成的图像,就会出错 例如: 2 2 1 1 1 3 答案是:3 而
阅读全文
摘要:已知方程为ax+by=c,现给出a,b,求max(c)对方程x,y无自然数解 数据保证c有最大值 题目保证了c没有上界,所以gcd(a,b)=1互质 根据数学结论,max(c)=a*b-a-b 证明:二元一次不定方程ax+by=N,gcd(a,b)=1,a>1,b>1 当N>ab-a-b时有非负整数
阅读全文

浙公网安备 33010602011771号