diff --git a/AB问题.java b/AB问题.java new file mode 100644 index 0000000..a29134e --- /dev/null +++ b/AB问题.java @@ -0,0 +1,87 @@ +package LanQiaoOJ; +/*1- A,B A+B*/ +import java.util.Scanner; +/* +public class LanqiaoOJ_0001 { + + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + while(sc.hasNext()) { + int a=sc.nextInt(); + int b=sc.nextInt(); + System.out.println(a+b); + } + } +} +*/ +//2-nʾnÿÿĺ͡ +/* +public class LanqiaoOJ_0001 { + + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + while(sc.hasNext()) { + int n=sc.nextInt();//м + for(int i=0;i0) { + if((n&1)==1) + count++; + n>>=1; + } + System.out.print(count); + } +} diff --git a/单词分析.java b/单词分析.java new file mode 100644 index 0000000..9e69e2b --- /dev/null +++ b/单词分析.java @@ -0,0 +1,38 @@ +package LanQiaoOJ; + +import java.util.Scanner; + +/* + * Сһʺ󣬰ҵĸ ĸֵĴ + +һаһʣֻСдӢĸɡеĵʳȲ 1000 + +УһаһӢĸʾгֵĸ +жĸֵĴȣֵСǸ +ڶаһʾֵǸĸڵгֵĴ*/ +public class ʷ { + static int N=1000; + static int [] a =new int [N]; + public static void main(String [] args) { + Scanner sc=new Scanner(System.in); + String s=sc.next(); + + for(int i=0;imax) { + max=a[i]; + ch=(char)(i+'a'); + } + + } + System.out.println(ch); + System.out.println(max); + } + +} diff --git a/卡牌.java b/卡牌.java new file mode 100644 index 0000000..35fe383 --- /dev/null +++ b/卡牌.java @@ -0,0 +1,18 @@ +package LanQiaoOJ; + +public class { +/*Ŀ +СкֿܶƬÿſƬ϶09 +С׼ЩƬƴһЩ1ʼƴÿƴһͱƬͲƴˡ +С֪Լܴ1ƴ١ +磬С30ſƬ093ţСƴ110 +ƴ11ʱƬ1Ѿֻһˣƴ11 +С09ĿƬ2021ţ20210ţ +СԴ1ƴ٣ +ʾʹü̽⡣*/ + public static void main(String[] args) { + + + } + +} diff --git a/含2天数.java b/含2天数.java new file mode 100644 index 0000000..7e52945 --- /dev/null +++ b/含2天数.java @@ -0,0 +1,65 @@ +package LanQiaoOJ; +/*2 + * Ŀ +Ϊ⣬ֻҪڴʹ佫ɡ +Сرϲ 2ǹԪ 2020꣬رˣΪÿ϶Կ 2 +ֻʾգʴӹԪ 1900 1 1 յԪ 9999 12 31 գһжϰ +2жյλа 2 +*/ +public class 2 { + //·±Ϊ1ʼ + static int[] w= {0,31,28,31,30,31,30,31,31,30,31,30,31}; + // + static int y=1900,m=1,d=1; + + public static void main(String[] args) { + int count=0; //ͳƺ2 + //ѭΪy=9999&&m=12&&d=31 + while(y!=9999||m!=12||d!=31) { + //жǷΪ + if(y%400==0||y%4==0&&y%100!=0) + w[2]=29; + else + w[2]=28; + //жǷҪ + if(check()) + count++; + //ڱ + d++; + if(d>w[m]) { + m++; + d=1; + } + if(m>12) { + y++; + m=1; + } + } + System.out.println(count+1); + } + + static boolean check() { + // TODO Auto-generated method stub + //ֱӲyΪһȫֱ + int a=y; + while(a>0) { + if(a%10==2) + return true; + a/=10; + } + int b=m; + while(b>0) { + if(b%10==2) + return true; + b/=10; + } + int c=d; + while(c>0) { + if(c%10==2) + return true; + c/=10; + } + return false; + } + +} diff --git a/啤酒与饮料.java b/啤酒与饮料.java new file mode 100644 index 0000000..142c68e --- /dev/null +++ b/啤酒与饮料.java @@ -0,0 +1,22 @@ +package LanQiaoOJ; +/*ơ + * Ŀ +ơÿ 2.3Ԫÿ 1.9ԪСơƺϣһ 82.3Ԫ +ǻ֪ơƱϵ٣˼ơơ*/ +public class ơ { + public static void main(String[] args) { + int x,y;//ֱʾơϵ + for(x=1;x<35;x++) + for(y=1;y<43;y++) { + if(x0){ + if(i%16>=10&&i%16<=15){ + i/=16; + }else{ + return false; + } + } + if(i>=10&&i<=15) { + return true; + } + return false; + } +} diff --git a/字符统计.java b/字符统计.java new file mode 100644 index 0000000..c6a1c45 --- /dev/null +++ b/字符统计.java @@ -0,0 +1,44 @@ +package LanQiaoOJ; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Scanner; + +/*һֻдĸַ S, гִַ +жĸ, ĸ˳Щĸ +ʽ +һֻдĸַ S. +ʽ +ɸдĸ𰸡 */ +public class ַͳ { + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + String s=sc.next(); + //ҪһȥͳÿֵַĴ + HashMaphashMap=new HashMap<>(); + for(int i=0;i list=new ArrayList<>(); + for(char key:hashMap.keySet()) { + int x=hashMap.get(key); + if(x>max) { + list.clear(); + list.add(key); + max=x; + }else if(x==max) { + list.add(key); + } + } + for(char c:list) { + System.out.print(c); + } + + } + + +} diff --git a/字符统计2.java b/字符统计2.java new file mode 100644 index 0000000..a50d5ff --- /dev/null +++ b/字符统计2.java @@ -0,0 +1,35 @@ +package LanQiaoOJ; + +import java.util.ArrayList; +import java.util.Scanner; + +public class ַͳ2 { + static int[] a=new int[26]; + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + String s=sc.next(); + //ҪһȥͳÿֵַĴ + + for(int i=0;ilist=new ArrayList<>(); + int max=0; + for(int i=0;i<26;i++) { + if(a[i]>max) { + list.clear(); + max=a[i]; + list.add(i); + }else if(a[i]==max) { + list.add(i); + } + } + for(int i:list) { + System.out.print((char)(i+'A')); + } + } + +} diff --git a/完全日期.java b/完全日期.java new file mode 100644 index 0000000..38dabc5 --- /dev/null +++ b/完全日期.java @@ -0,0 +1,63 @@ +package LanQiaoOJ; +/*ȫ*/ +/*һյĸλ֮ȫƽΪһȫڡ +磺2021 6 5 յĸλ֮Ϊ 2+0+2+1+6+5=16 16 һȫƽ 4 ƽ + 2021 6 5 һȫڡ +磺2021 6 23 յĸλ֮Ϊ 2+0+2+1+6+2+3=16һȫƽ 2021 6 23 Ҳһȫڡ +ʣ 2001 1 1 յ 2021 12 31 Уһжٸȫڣ*/ +public class ȫ { + //ÿ±1ʼ + static int [] w= {0,31,28,31,30,31,30,31,31,30,31,30,31}; + // + static int y=2001,m=1,d=1; + + public static void main(String[] args) { + int count=0; + //ѭ + while(y!=2021||m!=12||d!=31) { + //жǷꡪ>ж2 + if(y%400==0||y/400==0&&y/100!=0) + w[2]=29; + else + w[2]=28; + //жǷȫƽ + if(check()) + count++; + //ڱ + d++; + if(d>w[m]) { + m++; + d=1; + } + if(m>12) { + y++; + m=1; + } + } + System.out.print(count); + } + static boolean check() { + //ͳ + int sum=0; + //yΪȫֱֱӸĶ + int a=y; + //óݸ֮ + while(a>0) { + sum+=a%10; + a/=10; + } + int b=m; + while(b>0) { + sum+=b%10; + b/=10; + } + int c=d; + while(c>0) { + sum+=c%10; + c/=10; + } + //жǷΪƽ + int mark=(int)Math.sqrt(sum); + return mark*mark==sum; + } +} diff --git a/寻找三个数的最大乘积.java b/寻找三个数的最大乘积.java new file mode 100644 index 0000000..33743be --- /dev/null +++ b/寻找三个数的最大乘积.java @@ -0,0 +1,36 @@ +package LanQiaoOJ; + +import java.util.Scanner; + +/*题目描述 +实现一个算法在数组中找到 3 个数字的最大乘积。介绍如下: +例如数组 [5, -2, 3, 1, -1, 4] 中 3 个数字的最大乘积为 60。 +输入描述 +第一行为数字N (3≤N≤1000),表示数组元素的个数。 +第二行为数组元素 Ai,−1000≤Ai≤1000。 +输出描述 +输出一行,为 3 个数字的最大乘积。 + */ + +public class 寻找三个数的最大乘积 { + static int N=1010; + static int []a=new int [N]; + + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + int n=sc.nextInt(); + for(int i=0;ilist=new ArrayList<>(); + for(int i=0;ians?"No":"Yes"); + } +} diff --git a/成绩分析.java b/成绩分析.java new file mode 100644 index 0000000..8410a02 --- /dev/null +++ b/成绩分析.java @@ -0,0 +1,45 @@ + +package LanQiaoOJ; + +import java.util.Scanner; + +/* + * Ŀ +Сѧ֯һԣܷΪ100֣ÿ +ѧĵ÷ֶһ0100 +οԵ߷֡ͷֺƽ֡ + +ĵһаһn(1n104)ʾ + +Уÿаһ0100ʾһѧ +ĵ÷֡ + +С +һаһʾ߷֡ +ڶаһʾͷ֡ +аһʵ뱣λСʾƽ֡*/ +public class ɼ { + static int [] a =new int [10000]; + + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + double s=sc.nextInt(); + int sum=0,max=0,min=110; + for(int i=0;imax) { + max=a[i]; + } + if(a[i]=60){ + if(arr[i]>=85){ + mark++; + } + count++; + } + } + System.out.println((Math.round(count*100)/n)+"%"); + System.out.println(Math.round((mark*100)/n)+"%"); + } +} diff --git a/数数.java b/数数.java new file mode 100644 index 0000000..c1f6cfd --- /dev/null +++ b/数数.java @@ -0,0 +1,30 @@ +package LanQiaoOJ; +/* + * +κһ1ֽܱΪɸ +ˣ28=227ֽΪˡ +[2333333,23333333]жٸ +ԱֽΪ12ˣ*/ +public class { + static int ans=0; + public static void main(String[] args) { + for(int i=2333333;i<2333333;i++) { + int t=i; + + int x=0; + for(int j=2;j1) { + x++; + } + if(x==12) + ans++; + } + System.out.print(ans); + } + +} diff --git a/星期几.java b/星期几.java new file mode 100644 index 0000000..272c041 --- /dev/null +++ b/星期几.java @@ -0,0 +1,46 @@ +package LanQiaoOJ; +/*Ŀ +Ϊ⣬ֻҪڴʹ佫ɡ +1949 Ĺڣ 10 1 գ +꣨2012Ĺһ +ôӽڣмιأ +ҪдЩֻ꣬ҪһĿ*/ +public class ڼ { + //ÿ±1ʼ + static int [] w= {0,31,28,31,30,31,30,31,31,30,31,30,31}; + // + //t=0ʾ죬t=1ʾһ + static int y=1949,m=10,d=1,t=6; + + public static void main(String[] args) { + int count=0; + //ѭ + while(y!=2012||m!=10||d!=1) { + //жǷꡪ>ж2 + if(y%400==0||y/400==0&&y/100!=0) + w[2]=29; + else + w[2]=28; + //жǷȫƽ + if(check()) + count++; + //ڱ + d++; + // + t++; + t%=7; + if(d>w[m]) { + m++; + d=1; + } + if(m>12) { + y++; + m=1; + } + } + System.out.print(count); + } + static boolean check() { + return m==10&&d==1&&t==0; + } +} diff --git a/星期计算.java b/星期计算.java new file mode 100644 index 0000000..3d3e14f --- /dev/null +++ b/星期计算.java @@ -0,0 +1,19 @@ +package LanQiaoOJ; +/* + * +Ϊ⣬ֻҪڴʹ +佫ɡ +֪20^22ڼ +ע17ʾһա*/ +public class ڼ { + + public static void main(String[] args) { + int ans=1; + for(int i=0;i<22;i++) { + ans*=20; + ans%=7; + } + System.out.print(ans+6); + } + +} diff --git a/最大化交易利润.java b/最大化交易利润.java new file mode 100644 index 0000000..ce49457 --- /dev/null +++ b/最大化交易利润.java @@ -0,0 +1,37 @@ +package LanQiaoOJ; + +import java.util.Scanner; + +/* + * ʵһ㷨Ѱ󻯹ƱIJԡ£ +Ʊ۸ÿ춼ڱ仯ʾգԪرʾÿĹƱ۸ +ͨһֻܽһһΪһν״ +ֻܽһΣʹĽײԡ + +һΪN,ʾN졣 +ڶΪNA,ʾÿĹƱ۸ +У1N,A104**/ +public class 󻯽 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + Scanner sc=new Scanner(System.in); + int n=sc.nextInt(); + int []a=new int[n]; + for(int i=0;i0) + ans=Math.max(ans, a[i]-min); + min=Math.min(min, a[i]); + } + System.out.print(ans); + } + +} diff --git a/查找两个总和为特定值的索引.java b/查找两个总和为特定值的索引.java new file mode 100644 index 0000000..7bdcf01 --- /dev/null +++ b/查找两个总和为特定值的索引.java @@ -0,0 +1,35 @@ +package LanQiaoOJ; +/*Ŀ +һ飬ҵܺΪضֵ + [1, 2, 3, -2, 5, 7]ܺ 7򷵻 [1, 4] +жССһ顣 + +һΪijȣ 100 +ڶΪԪأԪشС 100Ϊ +Ϊضֵ + +һУΪֵ*/ + +import java.util.Scanner; + +public class ܺΪضֵ { + static int N=110; + static int [] a=new int[N]; + + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + int n=sc.nextInt(); + for(int i=0;imap=new HashMap<>(); + for(int i=0;i1) + System.out.print(n); + } +} +/*˷OJ޷ͨʱƽ + * public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + long n=sc.nextLong(); + + for(long i=2;ik) { + System.out.print(-1); + return; + } + } + + } + public static long Fun(long n) { + long ans=0; + while(n>0) { + //15105ĸ + ans=ans+n/5; + n=n/5; + } + return ans; + } +} diff --git a/熊怪吃核桃.java b/熊怪吃核桃.java new file mode 100644 index 0000000..ce76aff --- /dev/null +++ b/熊怪吃核桃.java @@ -0,0 +1,18 @@ +package LanQiaoOJ; +/*ֳܹԺ + ɭһֻܹ֣ܰԺҡиϰߣÿζҵĺҷֳȵݣ + * Եһݣһݡܵȷ֣ܹ־ͻӵһٷ֡ + * ڶټֱ̣ʣһˣֱӶ +һ죬ַܹ 1543 ңʣڳЩҵĹУһҪٸҡ*/ +public class ֳܹԺ { + public static void main(String[] args) { + int count=0;//ʾĺ + for(int n=1543;n>0;n/=2) { + if(n%2!=0) { + n--; + count++; + } + } + System.out.println(count); + } +} \ No newline at end of file diff --git a/特殊的数字.java b/特殊的数字.java new file mode 100644 index 0000000..7b9634f --- /dev/null +++ b/特殊的数字.java @@ -0,0 +1,20 @@ +package LanQiaoOJ; +/* + * +153һdzÿλֵͣ153=1*1*1+5*5*5+3*3*3λʮ +ʽ +С˳λʮÿռһ +*/ +public class { + public static void main(String[] args) { + int a,b,c;//ʾĸλʮλλ + for(int num=100;num<1000;num++) { + a=num%10;//10࣬õλֵ + b=num%100/10;//ȶ100࣬ٶ10ȡõʮλϵֵ + c=num/100;//100ȡõλϵֵ + if(num==a*a*a+b*b*b+c*c*c) { + System.out.print(num+" "); + } + } + } +} diff --git a/用杂志拼接信件.java b/用杂志拼接信件.java new file mode 100644 index 0000000..64187c3 --- /dev/null +++ b/用杂志拼接信件.java @@ -0,0 +1,49 @@ +package LanQiaoOJ; + +import java.util.HashMap; +import java.util.Scanner; +import java.util.Map; + +/*־ƴż + * + * ־żַɣڸ־żȷżǷ־ϵַɡ +־Ϊ abżΪ aaܹɡ־Ϊ aabżΪ aaԹɡ + +ַȾ 100 +һΪ־ַڶΪżַ + +һУż־ YES NO +ʾ + +ab +aa + +NO */ + +public class ־ƴż { + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + String s=sc.next(); //־ + String t=sc.next(); //ż + Mapms=new HashMap<>(); + Mapmt=new HashMap<>(); + + for(int i=0;i arr=new ArrayList<>(); + //numӣnumƽԼ + for(long i=1;i1) { + System.out.println(n+" "+1); + count++; + } + System.out.println(count); + } +} diff --git a/跑步锻炼.java b/跑步锻炼.java new file mode 100644 index 0000000..30a1771 --- /dev/null +++ b/跑步锻炼.java @@ -0,0 +1,46 @@ +package LanQiaoOJ; +/* + * Сÿ춼塣 +£Сÿ1סijһ³(1)Ϊ˼ԼСҪ2סͬʱһ +³СҲ2סСܲѾ˺ܳʱ䣬200011()2020101ģ) +ʱСܹܲٸף*/ +public class ܲ { + //ÿ + static int []w= {0,31,28,31,30,31,30,31,31,30,31,30,31}; + // + //t=1ʾһt=0ʾ + static int y=2000,m=1,d=1,t=6; + static int count=0; + public static void main(String[] args) { + // TODO Auto-generated method stub + + while(y!=2020||m!=10||d!=1){ + if(y%400==0||y/400==0&&y/100!=0) + w[2]=29; + else + w[2]=28; + if(d==1||t==1) { + count+=2; + } + else { + count++; + } + d++; + t++; + t%=7; + if(d>w[m]) { + m++; + d=1; + } + if(m>12) { + y++; + m=1; + } + if(y==2020&&m==10&&d==1) { + count+=2; + } + } + System.out.print(count); + } + +} diff --git a/门牌制作.java b/门牌制作.java new file mode 100644 index 0000000..81d1038 --- /dev/null +++ b/门牌制作.java @@ -0,0 +1,23 @@ +package LanQiaoOJ; +/* + * СҪΪһֵסƺš +һ 2020 λסƺŴ 1 2020 š +СƵķ 0 9 ⼸ַҪַճϣ + 1017 Ҫճַ1017Ҫ +1 ַ 02 ַ 11 ַ 7 +Ҫе 1 2020 ƣܹҪٸַ 2*/ +public class { + public static void main(String[] args) { + int count=0; + for(int i=1;i<=2020;i++) { + String numStr=Integer.toString(i); + + for(int j=0;j0) { + if(x%10==2) { + count++; + } + x/=10; + } + } + System.out.print(count); + } +}