临阵磨枪,不快也光
寸铁蓝桥杯系列指南
蓝桥杯刷题总结
第三期 考前必背技巧
数组范围适当开大
看数据范围,数据大记得开Long!!!
全局变量:
static int n,m;
定义了全局变量后,主方法不能再定义
否则会无效,不然调试时找半天!!!
正确写法:
public static void main(String []args){
n=sc.nextInt();
m=sc.nextInt();
}
快读快写:
注意:主方法中抛出异常!!!
常用模板1
public static void main(String []args)throws IOException{
BufferedReader bf=new BufferedRader(new InputStreamReader(System.in));
PrintWriter pw=new PrintWriter(new OutputStreamWriter(System.out));
int n=Integer.parseInt(bf.readLine());
String s[]=bf.readLine().split(" ");
for(int i=0;i<n;i++){
a[i]=Integer.parseInt(s[i]);
}
}
常用模板2(读入二维字符矩阵)
public static void main(String []args)throws IOException{
BufferedReader bf=new BufferedRader(new InputStreamReader(System.in));
PrintWriter pw=new PrintWriter(new OutputStreamWriter(System.out));
int n=Integer.parseInt(bf.readLine());
char g[][]=new char[n+10];
String s[]=bf.readLine().split(" ");
for(int i=0;i<n;i++){
char a[]=bf.readLine().toCharArray();
for(int j=0;j<n;j++){
g[i][j]=a[j];
}
}
}
读入一个数 1:
int n=Integer.parseInt(bf.readLine());
读入一个数 2:
String s[]=bf.readLine().split(" ");
int n=Integer.parseInt(s[0]);
读入多个数:
String s[]=bf.readLine().split(" ");
int a=Integer.parseInt(s[0]);
int b=Integer.parseInt(s[1]);
int c=Integer.parseInt(s[2]);
读入n个数:
String s[]=bf.readLine().split(" ");
int a[]=new int[N];
for(int i=1;i<=n;i++){
a[i]=Integer.parseInt(s[i-1]);
}
骗分技巧
原则:
稳住心态,有什么大不了,冷静下来思考每一题,能拿一分是一分。
暴力出奇迹,打表过样例!
不开longlong见祖宗,多多模拟必成功!
打表过样例:
先把代码跑出来,写成数组/特判(if-else)的查表形式输出答案。
尽可能多过一些样例!
如果样例比较多,直接给出来。不会做,直接输出样例!
能拿一分是一分!!!
如:迷宫问题,无解输出-1
。
想都不用想,至少有一个答案是无解。
数组适当开大一些!
细心细心细心,我们都叫细心!!!
检查
我们在检查时不需要去debug,太耗时。
直接在你想查的位置打印当前的结果即可
如:想验证一下check里面的i是否满足条件
直接在想查的语句后面打印内容,再去检查逻辑有无问题!
打印检查输出内容真的很重要!!!
必读补充资源
大家一定要去look
Java使用:http://t.csdn.cn/ATCD4
填空题:http://t.csdn.cn/PnWq0
混分:http://t.csdn.cn/BXKOy
寸铁好评