07 2020 档案

摘要:就是那个位运算,,,,,我又想多了emmmmm' 其实不同的位对应不同的递归而已 那个& 别弄错逻辑 如果有,就不能走!!! 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 5 using namespace std; 6 阅读全文
posted @ 2020-07-29 16:37 安之若醇 阅读(119) 评论(0) 推荐(0) 编辑
摘要:我感觉到了是dfs,但是我不是很会搞它(2017年题好难啊!!!) 本小白以为也是跟以前的连通块似的,按格子来找坐标 后来发现不太行 而且一定要注意根据对称性会有四个是一样的,如果按格子来的话很难判断 所以这个题是看分割线的 从中心点往左走,然后右边的也一起标记(因为对称) 最后的答案要除以4,因为 阅读全文
posted @ 2020-07-29 15:48 安之若醇 阅读(173) 评论(0) 推荐(0) 编辑
摘要:bfs通解,,,用了set存放状态以保证第一次找到目标答案 1 // 2 // Created by snnnow on 2020/7/29. 3 // 4 5 #include<bits/stdc++.h> 6 using namespace std; 7 struct node { 8 stri 阅读全文
posted @ 2020-07-29 15:23 安之若醇 阅读(116) 评论(0) 推荐(0) 编辑
摘要:这个题,,,由于dfs是个bool型的,,,在递归的时候,忘记写return 然后就一直错orz 1 #include <iostream> 2 #include <string> 3 #include <cstring> 4 5 using namespace std; 6 string a[11 阅读全文
posted @ 2020-07-29 10:50 安之若醇 阅读(144) 评论(0) 推荐(0) 编辑
摘要:学一下咋优化: 其实本来看见这个题,你应该知道四个for循环可以解决 优化主要有两种方法,第一个是减小枚举的范围,第二个是减少层数 本题范围肯定是减少不了了, 看一下层数: 最后那个d,其实可以用N-a^2-b^2-c^2来算 如果能开出来就是可以 其实还是不太行emmmm 如果再优化,可以先把c^ 阅读全文
posted @ 2020-07-28 18:05 安之若醇 阅读(134) 评论(0) 推荐(0) 编辑
摘要:今天发现很少写dfs.. dfs主要思想是递归 bfs主要靠队列 先说一下这个题我被阻了半个小时的地方: 1读数一定要注意scanf的吃回车 2注意数据类型为char,判断时是'0' dfs: #include <iostream> #include <string> #include <strin 阅读全文
posted @ 2020-07-28 16:38 安之若醇 阅读(208) 评论(0) 推荐(0) 编辑
摘要:(这个得慢慢更,我看见啥更啥的那种) 这个是输出二进制: for (int j = 0; j < 32; ++j) { printf("%d",(x>>(31-j))&1);//把一个数的二进制数全部输出 } 取出x最右边那个1:(八皇后二进制代码) 把最左边的1改成0 把左边连续的1改成0: 因为 阅读全文
posted @ 2020-07-27 18:32 安之若醇 阅读(240) 评论(0) 推荐(0) 编辑
摘要:又是一个全排列哈, 注意注意,这个题不是十三个数字都需要,但原理是一样的 一开始把for的边界写错了(每次其实应该从k开始,还没看出来orz) #include <iostream> #include <string> #include <string.h> #include <vector> #i 阅读全文
posted @ 2020-07-27 17:34 安之若醇 阅读(99) 评论(0) 推荐(0) 编辑
摘要:用的递推 首先要注意需要排序(结构体排序用sort+<的重载) 其实又开了一个数组用来存数...只不过结构体排序能方便很多 1 #include <iostream> 2 #include <string> 3 #include <string.h> 4 #include <vector> 5 #i 阅读全文
posted @ 2020-07-27 15:28 安之若醇 阅读(155) 评论(0) 推荐(0) 编辑
摘要:挖坑填数:1.i =L; j = R; 将基准数挖出形成第一个坑a[i]。2.j--由后向前找比它小的数,找到后挖出此数填前一个坑a[i]中。3.i++由前向后找比它大的数,找到后也挖出此数填到前一个坑a[j]中。4.再重复执行2,3二步,直到i==j,将基准数填入a[i]中。 1 int Adju 阅读全文
posted @ 2020-07-27 11:38 安之若醇 阅读(124) 评论(0) 推荐(0) 编辑
摘要:注: 顶上那个check()是判断是否满足题意 其实如果是不重复的元素的话,直接用next_permulation函数就好的 记忆一下: 先写一个for(需要注意范围) 然后两个交换 在两个交换之间整一个回溯 最顶上写递归边界. 阅读全文
posted @ 2020-07-26 22:30 安之若醇 阅读(102) 评论(0) 推荐(0) 编辑
摘要:这个题真是当时想麻烦了,,,感谢LLdl 提供的题解 其实一个很重要的点就是,如果后面的玩意翻转了偶数次,那就跟没变一样.如果是奇数次就取反. 怪我天真,第一反应就去位运算去了,,,,哪有那么复杂诶 害,,,,,,,,dl就是厉害 阅读全文
posted @ 2020-07-26 17:03 安之若醇 阅读(125) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <string> #include <string.h> #include <vector> #include <time.h> using namespace std; char a[110],b[110]; int dp[110][110 阅读全文
posted @ 2020-07-26 10:22 安之若醇 阅读(150) 评论(0) 推荐(0) 编辑
摘要:看如下代码:(三个一维) 1 #include <iostream> 2 #include <string> 3 #include <string.h> 4 #include <vector> 5 #include <time.h> 6 using namespace std; 7 long MAX 阅读全文
posted @ 2020-07-25 14:57 安之若醇 阅读(620) 评论(0) 推荐(0) 编辑
摘要:我看以前写过一个最长不下降,但是感觉可能没有那么好理解emmmm 下面这个是从正序寻找的emmmm 先来一个WA代码,我给写了WA的具体行数,看看其他行其实可以看出它的思路 第二个代码是AC的 1 #include <iostream> 2 #include <string> 3 #include 阅读全文
posted @ 2020-07-25 14:49 安之若醇 阅读(129) 评论(0) 推荐(0) 编辑
摘要:这个,输出为1 这个,啥都输不出来. 据说是因为没有初始化. 其实我搜了一下 1 vector<vector<int> > A;//正确的定义方式 2 vector<vector<int>> A;//c++11之前这样定义是错误的,c++11之后支持这种定义方式 因为>>会被认为是右移运算符 但是c 阅读全文
posted @ 2020-07-25 12:09 安之若醇 阅读(958) 评论(0) 推荐(0) 编辑
摘要:这个题,第一反应一定是三个for嵌套加一个max比较. 超级无敌大暴搜 #include <iostream> #include <string> #include <string.h> using namespace std; long MAX=0; int main(){ long m[1000 阅读全文
posted @ 2020-07-24 22:37 安之若醇 阅读(137) 评论(0) 推荐(0) 编辑
摘要:这个题目的背景概况来讲就是基于泰坦尼克号这个事件,然后大量的人员不幸淹没在这个海难中,也有少部分人员在这次事件之中存活,然后这个问题提供了一些人员的信息如姓名、年龄、性别、票价,所在客舱等等一些信息,和是否获救,然后你建模分析,去预测另一批乘客的获救与否 py小白的无助呀~ 尽管还算是写了这么写东西 阅读全文
posted @ 2020-07-23 17:09 安之若醇 阅读(265) 评论(0) 推荐(0) 编辑
摘要:记录一下--一个名叫vj的地方把我的回溯代码一直wa,,, 逼我现学位运算~~~~ #include <iostream> #include <string> #include <string.h> using namespace std; long sum = 0, upperlim = 1; v 阅读全文
posted @ 2020-07-23 15:48 安之若醇 阅读(222) 评论(0) 推荐(0) 编辑
摘要:冻龟之前 先看地龟 1 // 2 // Created by snnnow on 2020/7/23 3 // 4 //递归算法,除了慢其实还好 5 #include<iostream> 6 #include<stdio.h> 7 #include<stdlib.h> 8 #include<time 阅读全文
posted @ 2020-07-23 11:46 安之若醇 阅读(150) 评论(0) 推荐(0) 编辑
摘要:好久真的是好久没有做dp的问题了(QWQ)(我有学过这玩意???) 诶,人生呐! 今天来一个动归~ 顺便可以回顾一下dfs. 这个题我觉得审题也非常重要 小可爱dp: 1 #include <bits/stdc++.h> 2 using namespace std; 3 int f[201],n,i 阅读全文
posted @ 2020-07-22 17:16 安之若醇 阅读(146) 评论(0) 推荐(0) 编辑
摘要:#include<iostream> #include<stdio.h> #include<stdlib.h> #include<time.h> #include <queue> using namespace std; int N=0; int ax[8]={0,0,1,-1,1,1,-1,-1} 阅读全文
posted @ 2020-07-19 19:30 安之若醇 阅读(179) 评论(0) 推荐(0) 编辑
摘要:1 /* 2 * 换行好烦人呀! 3 */ 4 #include <iostream> 5 #include <map> 6 #include <string> 7 using namespace std; 8 map<string,map<string,int>> m; 9 int N; 10 i 阅读全文
posted @ 2020-07-19 12:30 安之若醇 阅读(240) 评论(0) 推荐(0) 编辑
摘要:在Preferences->Package Setting->Package Control ->Setting User 中,可以进行用户设置,我们可以将文件下载后,进行本地访问。首先访问https://packagecontrol.io/channel_v3.json(和底下的是一样的) ,将源 阅读全文
posted @ 2020-07-17 18:13 安之若醇 阅读(1244) 评论(0) 推荐(0) 编辑
摘要:subimeClang需要手动配置我真的真的很服 记录一下满是报错的高光时刻 ~~~~~~~~ 不过这个问题刚刚解决了 只要把所有的shared_ptr改成std::shared_ptr 就行 说白了就是命名空间的问题 好了,来点福利, 精华键 :Ctrl+Shift+P:打开命令面板Ctrl+P: 阅读全文
posted @ 2020-07-17 17:47 安之若醇 阅读(435) 评论(0) 推荐(0) 编辑
摘要:pycharm 内置虚拟环境 venv 如果要退出就直接 deactivate 命令就行 运行的话直接在命令行输python3 文件名 阅读全文
posted @ 2020-07-16 22:54 安之若醇 阅读(2152) 评论(0) 推荐(0) 编辑
摘要:上一道题,,,把if条件写错了,,,,找了半天的bug我都快哭了, 好了好了 看见这种填空题,先理解题意 然后把代码copy下来,把空格注释掉,然后运行到编译没有错. 再理一下它的思路 1 // 2 // Created by snnnow on 2020/7/15. 3 // 4 //要注意一一下 阅读全文
posted @ 2020-07-15 22:28 安之若醇 阅读(173) 评论(0) 推荐(0) 编辑
摘要:一开始写错了呜呜呜 先是<< 再是>> 阅读全文
posted @ 2020-07-15 22:11 安之若醇 阅读(155) 评论(0) 推荐(0) 编辑
摘要:map() 看一下我的终端咋说: map()的函数用法: map(function, iterable, ...)看一下具体例子: 注意的是一定要强制转化一下才能输出 也可以写匿名函数: (markdown版 reduce(): 阅读全文
posted @ 2020-07-15 18:24 安之若醇 阅读(208) 评论(0) 推荐(0) 编辑
摘要:这个题,一开始犯了一个很幼稚的错误 贴贴代码 #include<iostream> #include<stdio.h> #include<stdlib.h> #include<time.h> #include <strings.h> #include <queue> #include <set> # 阅读全文
posted @ 2020-07-14 22:58 安之若醇 阅读(168) 评论(0) 推荐(0) 编辑
摘要:最近状态出了点问题呜呜呜,可能是天有点热吧加上有一点点不太舒服,,,稳住啊! 明显一个递归(但是就是不会写) 递归:(一般这种找有多少个的题,返回值都是int) 首先找变化的东西当作参数.(本题是坐标) 再找重复的问题(递归调用) 最后找出口(千万别忘) 看起来其实也比较简单,,有点类似于前几天上楼 阅读全文
posted @ 2020-07-14 22:10 安之若醇 阅读(99) 评论(0) 推荐(0) 编辑
摘要:这个题方向其实还算好找,就是枚举嘛 (这是一个填空题,所以六个for嵌套也无所谓,因为毕竟emmmm,不看时间) 这里是判断的代码: 需要把数字转化成字符串 void i2s(int x,string &s){//注意是个引用 stringsream ss; ss>>x; ss<<s; } bool 阅读全文
posted @ 2020-07-13 22:58 安之若醇 阅读(136) 评论(0) 推荐(0) 编辑
摘要:诶,今天发生了点不是很开心的事.说实话挺影响心情的啊(谁遇见这种事不生气呢啊啊啊啊) 但是不能水更,还是得好好更新呀. 这个题居然直接用excel哈哈哈哈 那,,就这样吧! 阅读全文
posted @ 2020-07-13 22:11 安之若醇 阅读(109) 评论(0) 推荐(0) 编辑
摘要:刚刚不小心进入了命令行界面,,,,,, ALT SHIFE F5 咋回去的呢 sudo startx 但是回去以后默认是root ,,,,,, 所以切换用户 su username//用户名 就可以切换至普通用户(不过我只在命令行看见了我普通用户的文件,没有在图形界面看见) sudo su 切换超级 阅读全文
posted @ 2020-07-12 22:35 安之若醇 阅读(823) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-07-12 22:28 安之若醇 阅读(135) 评论(0) 推荐(0) 编辑
摘要:为什么第二题就这么难呜呜呜,这不是为难我吗!!! 可以明确的是,又是一个bfs 最少路径,找满足条件的那个层数 1 #include<iostream> 2 #include<stdio.h> 3 #include<stdlib.h> 4 #include<time.h> 5 #include <s 阅读全文
posted @ 2020-07-12 18:44 安之若醇 阅读(195) 评论(0) 推荐(0) 编辑
摘要:1 #include<iostream> 2 #include<stdio.h> 3 #include<stdlib.h> 4 #include<time.h> 5 #include <queue> 6 using namespace std; 7 int N,ans=0; 8 int ax[4]= 阅读全文
posted @ 2020-07-12 13:54 安之若醇 阅读(139) 评论(0) 推荐(0) 编辑
摘要:1 int read(){ 2 int x=0,f=1; 3 char ch=getchar(); 4 while(ch<'0'||ch>'9'){ 5 if(ch=='-') 6 f=-1; 7 ch=getchar(); 8 } 9 while(ch>='0'&&ch<='9'){ 10 x=( 阅读全文
posted @ 2020-07-12 11:30 安之若醇 阅读(260) 评论(0) 推荐(0) 编辑
摘要:如何在输入输出上提高一下效率emmmm 1 #include<iostream> 2 #include<stdio.h> 3 #include<stdlib.h> 4 #include<time.h> 5 using namespace std; 6 7 int main(){ 8 int star 阅读全文
posted @ 2020-07-12 11:18 安之若醇 阅读(782) 评论(0) 推荐(3) 编辑
摘要:差分,就是求本位与前一个的差. d[i]=a[i]-a[i-1] 一维差分一遍for循环就出来了呀. 有什么用呢? 这种: 1、将区间【1,4】的数值全部加上3 2、将区间【3,5】的数值全部减去5 在某一个数组全部加上或者减去某个东西,就可以用差分数组. 举个例子嗷嗷嗷 1 #include <i 阅读全文
posted @ 2020-07-11 21:45 安之若醇 阅读(153) 评论(0) 推荐(0) 编辑
摘要:现在看题有种感觉:只闻其名,不知其所云. 比如这个归并. 来吧来吧不多说了啊啊 1 #include <iostream> 2 #include <set> 3 #include <cstring> 4 5 using namespace std; 6 int a[10]={1,2,6,3,4,7, 阅读全文
posted @ 2020-07-09 22:38 安之若醇 阅读(118) 评论(0) 推荐(0) 编辑
摘要:首先找找规律,两者相加除以二. 按格式读入sscanf 按格式输出printf("02d%",m);前导0 1 #include <iostream> 2 #include <set> 3 #include <cstring> 4 5 using namespace std; 6 //快速幂运算 7 阅读全文
posted @ 2020-07-07 18:05 安之若醇 阅读(147) 评论(0) 推荐(0) 编辑
摘要:我自己一开始想的差不多,但是好像想得是vector+sort.... 直接用set它不香吗? 还有就是寻找下一个数的时候,没有用upperbound,,, 我想的大概是遍历一遍(就是用for对这个函数进行实现) 但是很慢,,, 那就s.upper_bound 1 #include <iostream 阅读全文
posted @ 2020-07-07 15:58 安之若醇 阅读(151) 评论(0) 推荐(0) 编辑
摘要:果然是练思维呀!!要是我的话估计就能挨个算一算呜呜呜 分解成 2和5相乘的式子 1 #include <iostream> 2 using namespace std; 3 //快速幂运算 4 5 int main(){ 6 int data[100]={}; 7 int num2=0; 8 int 阅读全文
posted @ 2020-07-06 21:59 安之若醇 阅读(111) 评论(0) 推荐(0) 编辑
摘要:1 int gcd(long a,long b){//条件a>b 2 if(b==0)return a; 3 return gcd(b,a%b); 4 } 阅读全文
posted @ 2020-07-06 21:39 安之若醇 阅读(116) 评论(0) 推荐(0) 编辑
摘要:1 //快速幂运算 2 long power_n(int n,int b){//n^b 3 long res=1;//注意是等于1 4 while(b>0){ 5 if(b&1)//取幂数的最后一位 6 res*=n; 7 b>>=1;//右移一位 8 n=n*n;//加权 9 10 } 11 re 阅读全文
posted @ 2020-07-06 21:37 安之若醇 阅读(111) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <algorithm> 3 4 using namespace std; 5 int a[100]; 6 int binarysearch(int a[],int size,int att){ 7 sort(a,a+size);//一 阅读全文
posted @ 2020-07-06 18:45 安之若醇 阅读(232) 评论(0) 推荐(0) 编辑
摘要:....又是以前虐过我的期末习题..哪里摔倒就哪里爬起来吧 1 #include<iostream> 2 #include<math.h> 3 #define N 1e-3 4 using namespace std; 5 6 bool IsZero(double a){ 7 return abs( 阅读全文
posted @ 2020-07-06 18:19 安之若醇 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-07-05 17:48 安之若醇 阅读(266) 评论(0) 推荐(0) 编辑
摘要:题外话: 某天晚上梦见更了五六篇博客而不知疲惫. 如果这是现实该多好啊哈哈哈!美梦成真吧! 中项表达式就是最普通的表达式.也是几个小定义来回递归.这个题在去年期末上机题中出现过,但是比这个还有难一些. 呜呜呜,去年的我啥都不会(当然现在也是),为难我干什么呀!!!! 解: 1 #include <i 阅读全文
posted @ 2020-07-05 17:31 安之若醇 阅读(158) 评论(0) 推荐(0) 编辑
摘要:挺简单的代码吧,,,就是那个return ...... 1 #include <iostream> 2 using namespace std; 3 int n; 4 void hanoi(int n,char src,char mid,char des){ 5 if(n==1){ 6 cout<< 阅读全文
posted @ 2020-07-05 15:54 安之若醇 阅读(150) 评论(0) 推荐(0) 编辑
摘要:1 /*可以用回溯,但是我已经不太熟悉回溯了!!!!!!!!呜呜呜 2 * 3 */ 4 #include <iostream> 5 #include <math.h> 6 using namespace std; 7 /* 8 * 这个地方我确实没有想到 9 * 我不知道怎么判断两个符号的作用对象 阅读全文
posted @ 2020-07-03 22:27 安之若醇 阅读(265) 评论(0) 推荐(0) 编辑
摘要:// // #include <stdio.h> /*可以用回溯,但是我已经不太熟悉回溯了!!!!!!!!呜呜呜 * */ #include <iostream> #include <math.h> using namespace std; int a[9]={0}; //bool b[100]={ 阅读全文
posted @ 2020-07-03 21:16 安之若醇 阅读(138) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include<string.h> 3 using namespace std; 4 char Lleft[3][100]; 5 char Lright[3][100]; 6 char result[3][100]; 7 bool wight(cha 阅读全文
posted @ 2020-07-02 22:45 安之若醇 阅读(174) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include<cstdio> 3 using namespace std; 4 int main(){ 5 int p,e,i,d; 6 int num=0; 7 while(1){ 8 cin>>p; 9 if(p 1) 10 break; 11 阅读全文
posted @ 2020-07-02 21:09 安之若醇 阅读(135) 评论(0) 推荐(0) 编辑
摘要:诶,为了期末,好久没有(其实也就一个月)写这玩意了emmmm 为了贯彻落实社会主义核心价值观,最近打算把程序算法的相关知识从头串一遍. (感觉自己学得好散,而且忘了一大半了QAQ) 这样的话每天能更几篇也没太有数,为了方便打算每个题都更一篇,(顺便刷刷总篇数(bushi)). 其实写写博客满满的收获 阅读全文
posted @ 2020-07-02 19:25 安之若醇 阅读(142) 评论(0) 推荐(0) 编辑

Live2D服务支持
点击右上角即可分享
微信分享提示