![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
王道机试指南
Simon_Paul
这个作者很懒,什么都没留下…
展开
-
KY210 排序
这题考察对algorithm里面sort的应用。#include<iostream>#include<algorithm>#include<vector>using namespace std;int main(){ int n; while(scanf("%d", &n) != EOF){ vector<int> line(n); for(int i=0; i<n; i++){原创 2022-01-18 12:22:38 · 285 阅读 · 0 评论 -
KY89 坠落的蚂蚁
这个题目用暴力模拟死路一条。。。Theramenes大佬的思路真是牛b!(坠落的蚂蚁__牛客网 (nowcoder.com)) 简单提炼一下就是:设整条木棍上共有N只蚂蚁,有n只向左,1只不会动的蚂蚁,m只向右,根据设定,蚂蚁相遇会换速度(矢量),即每一次相遇,都有两只蚂蚁交换阵营(三只相遇可视为两次相遇)。但因速度大小一致,即使改变了方向,两者的左右相对位置仍不会发生改变,这就是蚂蚁的相对位置永远不变的含义。不难看出,相遇发生的改变并不会影响 “整条木棍上共有N只蚂蚁,有n只向...原创 2022-01-14 23:48:55 · 294 阅读 · 0 评论 -
T2.10 路径打印
KY100 路径打印原创 2020-03-27 19:20:07 · 184 阅读 · 0 评论 -
T2.9 Grading
//it's a easy problem //if you can understand the judge rule#include<iostream>#include<algorithm>using namespace std;int main(){ int p,t,g1,g2,g3,gj; double g; while(sca...原创 2020-03-27 19:17:20 · 151 阅读 · 0 评论 -
E2.11 xxx定律
#include<iostream>using namespace std;int main(){ int n; while(scanf("%d",&n)!=EOF){ if(n==0) break; int cnt=0; while(n!=1){ if(n%2==0) n/=2;...原创 2020-03-27 19:16:37 · 160 阅读 · 0 评论 -
E2.10 手机键盘
//坑爹玩意,abc在2键上,pqrs在7键,wxyz在9键,让我用26键全键盘打字的好懵逼//算法思想:用数组先把abc分组标记#include<iostream>#include<string>using namespace std;int main(){ int key[128]={0}; char keys='a'; for(i...原创 2020-03-27 19:14:58 · 207 阅读 · 0 评论 -
E2.9 剩下的数
//算法思想1:使用标记数组,初始化为1,移走一颗置0累计首次置0次数//算法思想2:数学思想,取挖掉区间并集,最后减去挖去区间大小剩余便是所求;//使用思想1,思想2待实现#include<iostream>using namespace std;int main(){ int n,m; scanf("%d%d",&n,&m); ...原创 2020-03-27 19:13:50 · 145 阅读 · 0 评论 -
习题2.8-日期类
//算法思想:水题,不会有闰年,往上莽就是了#include<iostream>using namespace std;int num[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};int main(){ int n,y,m,d; scanf("%d",&n); for(int i=0;i<n;...原创 2020-03-26 12:11:17 · 611 阅读 · 0 评论 -
习题2.7-Day of Week
#include<iostream>#include<string>#include<map>using namespace std;//隐藏基准:1年1月1日为周一int num[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31, 0,31,29,31,30,31,30,31...原创 2020-03-26 11:58:45 · 167 阅读 · 0 评论 -
习题2.6-日期差值
#include<iostream>using namespace std;int num[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31, 0,31,29,31,30,31,30,31,31,30,31,30,31};int year[2]={365,366};int main(){ i...原创 2020-03-26 11:57:30 · 172 阅读 · 0 评论 -
习题2.5-Hello World for U
#include<iostream>#include<string>using namespace std; int main(){ int n1,n2,len; string str; cin>>str; len=str.length(); n1=n2=(len+2)/3; while(n1+n2+n1...原创 2020-03-26 11:56:44 · 201 阅读 · 0 评论 -
习题2.4-Repeater
#include<iostream>#include<string.h>using namespace std; //算法思路:将当前模板重复嵌入基础模板中const int maxn=3001;char m[maxn][maxn];//当前模板char tmp[maxn][maxn]; //暂存char base[6][6];//基础模板,用与嵌入in...原创 2020-03-26 11:55:44 · 203 阅读 · 0 评论 -
例2.8-日期积累
#include<iostream>using namespace std;int num[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31, 0,31,29,31,30,31,30,31,31,30,31,30,31};int main(){ int cnt,y,m,d,n; scanf...原创 2020-03-26 11:51:29 · 78 阅读 · 0 评论 -
例2.6-今年的第几天?
#include<iostream>using namespace std;int num[12]={31,28,31,30,31,30,31,31,30,31,30,31};int main(){ int y,m,d; while(scanf("%d %d %d",&y,&m,&d)!=EOF){ int day=0...原创 2020-03-26 11:49:54 · 89 阅读 · 0 评论 -
例2.7-打印日期
#include<iostream>using namespace std;int num[2][12]={31,28,31,30,31,30,31,31,30,31,30,31, 31,29,31,30,31,30,31,31,30,31,30,31};int main(){ int y,n; while(scanf("%d ...原创 2020-03-26 11:48:52 · 194 阅读 · 0 评论 -
习题2.3-Old Bill
#include<iostream>using namespace std;int main(){ int n,x,y,z,a,b; scanf("%d %d %d %d",&n,&x,&y,&z); int xyz=x*1000+y*100+z*10; int p=-1; for(a=9;a>0;a...原创 2020-03-26 11:45:58 · 308 阅读 · 0 评论 -
王道机试指南(第二版)算法目录
Example Name Link Finish Time 2.6 今年的第几天? http://t.cn/E9jXK5A 2020.3.25 2.7 打印日期 http://t.cn/E9YP2a8 2020.3.25 2.8 日期积累 http://t.cn/E9Yw0Cr 2020.3.26 ...原创 2020-03-26 11:37:33 · 3154 阅读 · 6 评论