赞
踩
本人菜鸡一枚,如有错误,评论区指正,本文主要为算法新手在比赛中骗分提供一些思路,这皆是我的一家之言,大伙看个乐就行了。
- public class Main{
- public static void main(String[] args) {
- long sum=0;
- long t=1000000000;
- long temp=1;
- for(int i=1;i<=100;i++){
- temp=(temp*i)%t;
- sum=(sum+temp)%t;
- }
- System.out.println(sum);
- }
- }
这题不能用暴力解决,毕竟10的11次方了。这题只要求观察出1!到39!之和后面的末尾9位数没有变过即可解决,如果有接触过这种类型题,可快速完成
- public class Main{
- public static void main(String[] args) {
- int count=0;
- while(true){
- for(long i=1;;i++){
- if(Is(i,2)&&Is(i,8)&&Is(i,10)&&Is(i,16)){
- count++;
- if(count==2023){
- System.out.println(i);
- return;
- }
- }
- }
- }
- }
- static boolean Is(long num,int n){
- long t=num;
- int sum=0;
- while(t!=0){
- sum=(int)(sum+(t%n));
- t/=n;
- }
- return num%sum==0;
- }
- }
答案:215040
简单进制转换。long换成int也是可以的,不会爆
- import java.util.Scanner;
-
- public class Main{
- static int T;
- static long ans=0;
- static int[] arr;
- public static void main(String[] args) {
- Scanner in=new Scanner(System.in);
- T=in.nextInt();
- while (T!=0){
- int n=in.nextInt();
- arr=new int[n+1];
- long sum=0;
- for (int i = 1; i <=n; i++) {
- arr[i]=in.nextInt();
- sum+=arr[i];
- }
- if (sum%2==0){
- ans++;
- }
- for (int i=1;i<=n;i++){
- bfs(i+1,sum,arr[i]);
- }
- System.out.println(ans);
- ans=0;
- T--;
- }
- }
- static void bfs(int next,long sum,long sum_temp){
- if(sum_temp%2==0&&(sum-sum_temp)%2==0){
- ans++;
- ans=ans%1000000007;
- }
- for (int i=next;i<arr.length;i++){
- bfs(i+1,sum,sum_temp+arr[i]);
- }
- }
- }
本人这题没有审题已寄,我以为是计算全部然后输出(样例的4,0是分页的),这题ans过大的话可能要用BigInteger处理。这题只需考虑{}和{全部}的关系,应该是能骗些分的
- import java.util.HashSet;
- import java.util.Scanner;
-
- public class Main{
- static HashSet<String> hs=new HashSet<>();
- public static void main(String[] args) {
- Scanner in=new Scanner(System.in);
- int x1,y1,x2,y2,x3,y3,x4,y4;
- x1=in.nextInt();
- y1=in.nextInt();
- x2=in.nextInt();
- y2=in.nextInt();
- x3=in.nextInt();
- y3=in.nextInt();
- x4=in.nextInt();
- y4=in.nextInt();
- for (int i=x1;i<x2;i++){
- for(int j=y1;j<y2;j++){
- String str=""+i+"-"+j;
- hs.add(str);
- }
- }
- for (int i=x3;i<x4;i++){
- for(int j=y3;j<y4;j++){
- String str=""+i+"-"+j;
- hs.add(str);
- }
- }
- System.out.println(hs.size());
- }
- }
模拟题,普通判断的话会有很多种情况,有时间的话可以思考一下,我大概估计有10+种,面积大应该会超时,骗分吧
- import java.util.HashSet;
- import java.util.Iterator;
- import java.util.Scanner;
-
- public class Main{
- static HashSet<String> hs=new HashSet<>();
- static long[] arr;
- static int[][] ab;
- static int n;
- static long x;
- static int y;
- static double t;
- public static void main(String[] args) {
-
- Scanner in=new Scanner(System.in);
- n=in.nextInt();
- arr=new long[n];
- for(int i=0;i<n;i++){
- arr[i]=in.nextLong();
- }
- ab=new int[n-1][2];
- for(int i=0;i<n-1;i++){
- ab[i][0]=in.nextInt();
- ab[i][1]=in.nextInt();
- }
- double min=Integer.MAX_VALUE;
- dfs("",0);
- Iterator<String> iterator = hs.iterator();
- while (iterator.hasNext()) {
- char[] next = iterator.next().toCharArray();
- t=arr[0];
- x=arr[0];
- y=0;
- get(next,0);
- t=t+(y-0)*(10*1.0/13);
- min=Math.min(t,min);
- }
- min+=0.005;
- System.out.println(String.format("%.2f",min));
- }
- static void get(char[] chars,int index){
- if(x==arr[n-1]){
- return ;
- }
- if (chars[index]=='0'){
- t=t+y*(10*1.0/13);
- t=t+arr[index+1]-arr[index];
- x=arr[index+1];
- y=0;
- }else{
- if (y>ab[index][0]){
- t=t+(y-ab[index][0])*(10*1.0/13);
- }else{
- t=t+(ab[index][0]-y)*(10*1.0/7);
- }
- x=arr[index+1];
- y=ab[index][1];
- }
- index++;
- get(chars,index);
- }
- static void dfs(String str,int count){
- if(count==n-1){
- hs.add(str);
- return;
- }
- char a='0',b='1';
- count=count+1;
- dfs(str+a,count);
- dfs(str+b,count);
- }
- }
只能过30%左右的数据,没办法就只能暴力,喜欢拼运气可以直接随机。这里我不知道是自愿传送还是碰到那个点就会传送
- import java.util.Scanner;
-
- public class Main{
- static int[][] arr1;
- static int[][] arr2;
- static int N;
- public static void main(String[] args){
- Scanner in=new Scanner(System.in);
- N=in.nextInt();
- arr1=new int[N][N];
- arr2=new int[N][N];
- for(int i=0;i<N;i++){
- for(int j=0;j<N;j++){
- arr1[i][j]=in.nextInt();
- }
- }
- for(int i=0;i<N;i++){
- for(int j=0;j<N;j++){
- arr2[i][j]=in.nextInt();
- }
- }
- int max=0;
- int max1=0;
- int max2=0;
- for(int i=0;i<N;i++){
- if(arr1[i][N-1]==1){
- max1=Math.max(max1,get(i,N-1));
- }
- if(arr1[N-1][i]==1){
- max1=Math.max(max1,get(N-1,i));
- }
- if(arr1[i][0]==1){
- max1=Math.max(max1,get(i,0));
- }
- if(arr1[0][i]==1){
- max1=Math.max(max1,get(0,i));
- }
- }
- max+=max1;
- for(int i=0;i<N;i++){
- if(arr2[i][N-1]==1){
- max2=Math.max(max2,get1(i,N-1));
- }
- if(arr2[N-1][i]==1){
- max2=Math.max(max2,get1(N-1,i));
- }
- if(arr2[i][0]==1){
- max2=Math.max(max2,get1(i,0));
- }
- if(arr2[0][i]==1){
- max2=Math.max(max2,get1(0,i));
- }
- }
- max+=max2;
- System.out.println(max);
- }
- static int get(int x,int y){
- int[][] arr=new int[N][N];
- for(int i=0;i<N;i++){
- for(int j=0;j<N;j++){
- arr[i][j]=arr1[i][j];
- }
- }
- arr1[x][y]=2;
- if(x-1>=0&&arr1[x-1][y]==1){
- bfs(x-1,y);
- }
- if(x+1<N&&arr1[x+1][y]==1){
- bfs(x+1,y);
- }
- if(y-1>=0&&arr1[x][y-1]==1){
- bfs(x,y-1);
- }
- if(y+1<N&&arr1[x][y+1]==1){
- bfs(x,y+1);
- }
- int count=0;
- for(int i=0;i<N;i++){
- for(int j=0;j<N;j++){
- if(arr1[i][j]==2){
- count++;
- }
- }
- }
- arr1=arr;
- return count;
- }
- static void bfs(int x,int y){
- arr1[x][y]=2;
- if(x-1>=0&&arr1[x-1][y]==1&&arr1[x-1][y]!=2){
- bfs(x-1,y);
- }
- if(x+1<N&&arr1[x+1][y]==1&&arr1[x+1][y]!=2){
- bfs(x+1,y);
- }
- if(y-1>=0&&arr1[x][y-1]==1&&arr1[x][y-1]!=2){
- bfs(x,y-1);
- }
- if(y+1<N&&arr1[x][y+1]==1&&arr1[x][y+1]!=2){
- bfs(x,y+1);
- }
- }
- static int get1(int x,int y){
- int[][] arr=new int[N][N];
- for(int i=0;i<N;i++){
- for(int j=0;j<N;j++){
- arr[i][j]=arr2[i][j];
- }
- }
- arr2[x][y]=2;
- if(x-1>=0&&arr2[x-1][y]==1){
- bfs1(x-1,y);
- }
- if(x+1<N&&arr2[x+1][y]==1){
- bfs1(x+1,y);
- }
- if(y-1>=0&&arr2[x][y-1]==1){
- bfs1(x,y-1);
- }
- if(y+1<N&&arr2[x][y+1]==1){
- bfs1(x,y+1);
- }
- int count=0;
- for(int i=0;i<N;i++){
- for(int j=0;j<N;j++){
- if(arr2[i][j]==2){
- count++;
- }
- }
- }
- arr2=arr;
- return count;
- }
- static void bfs1(int x,int y){
- arr2[x][y]=2;
- if(x-1>=0&&arr2[x-1][y]==1&&arr2[x-1][y]!=2){
- bfs1(x-1,y);
- }
- if(x+1<N&&arr2[x+1][y]==1&&arr2[x+1][y]!=2){
- bfs1(x+1,y);
- }
- if(y-1>=0&&arr2[x][y-1]==1&&arr2[x][y-1]!=2){
- bfs1(x,y-1);
- }
- if(y+1<N&&arr2[x][y+1]==1&&arr2[x][y+1]!=2){
- bfs1(x,y+1);
- }
- }
- }
bfs暴搜,选择最大值即可,也是考完才想起来直接报搜,大佬们看个乐就行了,明年蓝桥杯再见
总体难度比往年差不多,就是简单题不再是白送分了。第一次参加蓝桥杯也很紧张。点名批评一下广东某水利学院的设备和监考老师的态度,手机响了不管?害我开局少考20+分钟,紧张体验感拉满
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。