今年的比赛在线上进行,监考考场和学生的考试环境以及各种因素使得这次比赛已失去意义,无参考性,但此次蓝桥杯题目很有意思

1.裁剪刀

观察规律即可,代码附上:
public class Main{ public static void main(String[] args){
System.out.println(4+(20-1)+20*(22-1)); }
答案:443

2.根据表格规律寻找数字

观察表格可知此数是11和17的公倍数,再添加部分条件即可,比如11的倍数33、44,代码稍后附上,此题稍后更新,需要进行规律最大优化

三:

此题考察点在于我们对数据类型范围的掌握,两层for循环附上:
import java.util.Scanner; public class Main { public static void
main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt();
int[] nums=new int[n]; for(int x=0;x<n;x++) { nums[x]=sc.nextInt(); }
sc.close(); int sum=0; for(int i=0;i<n-1;i++) { for(int j=i+1;j<n;j++) {
sum=sum+nums[i]*nums[j]; } } System.out.println(sum); } }
 4.寻找k

寻找k使得公约数增大,这个题实际就是题目意思扰乱人,只要比原来大就好了,因为没有边界条件

 

 
import java.util.Scanner; public class Main{ public int gcd(int a,int b){
if(a==0 || b==0) { return 0; } return a%b==0?b:gcd(b,a%b); } public static void
main(String[] args) { Scanner sc=new Scanner(System.in); int x1=sc.nextInt();
int x2=sc.nextInt(); Main t=new Main(); int
Min=x1>x2?t.gcd(x1,x2):t.gcd(x2,x1); int k=1,temp=0,Ma=0,Mi=0;; if(x1>x2) {
temp=t.gcd(x1+k,x2+k); Ma=x1+k; Mi=x2+k; }else { temp=t.gcd(x2+k,x1+k);
Ma=x2+k; Mi=x1+k; } while(temp<=Min) { k++; temp=t.gcd(Ma+k,Mi+k); }
System.out.println(k); } }
5.蜂巢

 可以采用回溯或者dfs、bfs等,关键在如何选择边界条件。稍后更新,暂时不更,因为需要最优化判断。

。。。。。

6.全排列的价值

 此题采用数学方法即可
import java.util.Scanner; public class Main{ public static void main(String[]
args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if (n == 0
|| n == 1) { System.out.println(0); return; } long flag = 2; long count = 1;
for (int x= 3; x < n+1; x++) { count = ((count * x * (x - 1) / 2) % 998244353 +
(count * x) % 998244353) % 998244353; flag = (x * flag) % 998244353; }
System.out.println(count); } }
7.青蛙过河

看着题目长,明日更新此题,上面未做明日全部更新

8.因数平方和

 

 所给题目样例输出错误,傻逼的题目一个
import java.util.Scanner; public class Main{ public static void main(String[]
args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.close();
long[] arr = new long[n + 1]; long sum = 0; for (long i = 1; i < arr.length;
i++) { long j = i; while (j < arr.length) { arr[(int) j] = (arr[(int) j] + i *
i) % 1000000007; j += i; } sum = (sum + arr[(int) i]) % 1000000007; }
System.out.println(sum); } }
9.最优清0方案

代码附上,解题思路另写,此题动态规划即可,今天晚上附上,暂时因为论文暂时不更

 

技术
今日推荐
PPT
阅读数 121
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信