首页 > 编程知识 正文

第十届蓝桥杯山东省赛地点,第十一届蓝桥杯大赛

时间:2023-05-06 15:26:41 阅读:11277 作者:2184

思路:的问题是,是选择成绩峰值最大的5人,还是从平均值中选择5人达到峰值;

第一种情况答案是490

第二种情况没算

我以为考试时看不清问题的意思,求出了这些组数据的最大值,成功避开了问题的意思,所以第一个问题就随便凉快了~~。

想法:

剪切所有可能的字符串并将其放入hashmap

hashmap的特征是,有重复的字符串将复盖前面的字符串。

最后用map.size求出集合中的字符串个数

我的答案是100

代码:

import java.util.HashMap; public class main { publicstaticvoidmain (string [ ] args ) strings='01001100010001 '; //String s='abcd '; HashMapString,Integer map=new HashMap (; for(intI=0; i=s.length (; I ) for(intj=I1; j=s.length (; j ) {map.put(s.substring(I,j ),1 ); }system.out.println(map.size ); }

想法:这个问题有递归和递归两种方法,但是递归20190324的数字太大,会发生堆栈溢出,所以只能递归

我的回答是4659

代码:

import java.util.Scanner; public class main { publicstaticvoidmain (字符串[ ] args ) scannersc=newscanner ) system.in ); int n=sc.nextInt (; int a=1,b=1,c=1; for(intI=4; i=n; I ) inttemp=(abc ) 0000; //为了不超过最大整数,对于100000可取馀数A=B0000; b=c0000; c=temp; }system.out.println(c; }

想法:一切排列,保存一切情况

我个人认为40785是正确的

但是,我又成功避免了正确答案。 考试的时候写了299。 我最后做了这个问题,所以没有认真看。 忽略了问题中“”各不相同的“”四个字符。 真的有千万条路。 我必须去有洞的地方。 。

代码:

公共类主{ publicstaticvoidmain (字符串[ ] args ) {int n=2019; int t=0; LOOP:for(intI=1; i n; I () if ) (I ' ).indexof ) )2)!=-1||(I ' ) (.indexof ) )4)!=-1 ) continue; LOOP2:for(intj=I1; j n; j ) if(I==j )连续回路2; if ((j ' ).indexof ) )2)!=-1|||(j ' ).indexof ) (4)!=-1 ) continue; int k=n-i-j; if(k=0) break loop2; if(I==k )连续loop 2; if(j==k )连续loop 2; if ((k ) ).indexof ) )2)!=-1||(k ' ).indexof )4)!=-1 ) continue loop2; t; }system.out.println(t/3 ); }

import java.util.Scanner; public class main { publicstaticvoidmain (字符串[ ] args ) scannersc=newscanner ) system.in ); long n=sc.nextInt (; 长号=0; for(intI=1; i=n; I({strings=I ' ); if(s.indexof ) '2'!=-1|||s.indexof('0)!=-1|||s.indexof('1'!=-1|||s.indexof('9'!=-1 ) num =i; }system.out.println(num ); }

思路:按二维序列a [ http://www.Sina.com/1 ] [ http://www.Sina.com/1 ]存储订单数。 例如,在上面的测试示例中,二维阵列(其中行表示时间点,列表示商店编号)表示如下。

12345611110002000012然后按一维数组sum[ N1]存储各店优先级如下表: (行表示时间点) :

123456sum[1]246543sum[2]000026缓存中的店铺数量001111import java.util.HashMap; import java.util.Scanner; public class main { publicstaticvoidmain (字符串[ ] args ) scannersc=newscanner ) system.in ); int n=sc.nextInt (; int order=sc.nextInt (; int time=sc.nextInt (; int a[][]=new int[n 1][time 1]; int sum[]=new int[n 1]; HashMapInteger,Integer map=new HashMap (; for(intI=0; 输入订单; I ) ({int ts=sc.nextInt ); int id=sc.nextInt (; if(ts=time ) a[id][ts]; }for(intI=1; i n 1; I ) for(intj=1; j time 1; j () if ) a[I][j]==0) sum[I]=math.max(0,sum[i]-1 ); elsesum[i] =a[i][j]*2; if(sum[I]5) map.put(i ) I,1 ); if(sum[I]=3map.containskey(I ) ) map.remove(i ) I; }system.out.println(map.size ); }

想法:不管有多少个负号,如果是m0,结果就是所有的数加起来,减去最小值的两倍

e.g有四个负号公式。 a-(b-c-d-e ),其实只是少了一个数b。 把最小的数量给b就可以了。

T

你看了上面的公式可能产生了疑问,但你没说主题有括号吧。 为什么可以用括号? 让我们说一下这是什么是后缀表达式。N如果你还不明白,可以看看后缀表达式的详细介绍,这里就不多说了。

坑1:

主题在表达式转为后缀表达式的时候,括号是被抵消了,不会出现在最后的结果中在有200000个10^9加法的情况下超出整数显示范围,因此按数量进行了处理。 不知道是否超时。

代码:

import java.math.BigInteger; import java.util.Scanner; public class main { publicstaticvoidmain (字符串[ ] args ) scannersc=newscanner ) system.in ); int n=sc.nextInt (; int m=sc.nextInt (; bigintegermin=newbiginteger (1000000 ); bigintegersum=newbiginteger('0); int num=n m 1; for(intI=0; i num; I ) ) bigintegertemp=newbiginteger (sc.nextint () ) '); sum=sum.add(temp; min=temp.comPareto(min )==-1? temp:min; } system.out.println (sum.subtract (min.multiply ) newbiginteger('2' ) ) }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。

  • 相关阅读