public class Main{
public static void main(String[] args) {
System.out.println((int)'L');
}
}
B.卡片
public class Main{
public static void main(String[] args) {
int a[] = new int[10];
boolean flag = false;
for(int i=1;;i++) {
int t = i;
while(t!=0) {
a[t%10]++;
t/=10;
}
for(int j=0;j<10;j++) {
if(a[j]>=2021) {
System.out.println(i);
flag = true;
break;
}
}
if(flag)break;
}
}
}
C.直线
import java.util.HashSet;
public class Main{
//这里要特别注意要用double类型的,不然int会自动向下取整,导致结果错误
public static double gcd(double m,double n) {
if(m==0)return n;
else return gcd(m%n,m);
}
public static void main(String[] args) {
HashSet<String> hs = new HashSet<>();
for(int y1=0;y1<=20;y1++) {//a1的纵坐标
for(int x1=0;x1<=19;x1++) {//a1的横坐标
for(int y2=0;y2<=20;y2++) {//b1的纵坐标
for(int x2=0;x2<=19;x2++) {//b1的横坐标
if(x1==x2)hs.add("x="+x1);//k不存在的情况
else if(y1==y2)hs.add("y="+y1);
else {
//y=Kx+B
String K = ((y1-y2)/gcd(y1-y2,x1-x2))+"/"+((x1-x2)/gcd(y1-y2,x1-x2));
String B = (x1*y2-x2*y1)/gcd(x1*y2-x2*y1,x1-x2)+"/"+(x1-x2)/gcd(x1*y2-x2*y1,x1-x2);
if(x1*y2-x2*y1==0)B=""+0;
hs.add("y="+K+"*x"+"+"+B);
}
}
}
}
}
System.out.println(hs.size());
}
}
F.时间显示
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//怕爆int,所以开了大数
Scanner sc = new Scanner(System.in);
BigInteger T = sc.nextBigInteger();
BigInteger h = new BigInteger("1");
BigInteger m = new BigInteger("1");
BigInteger s = new BigInteger("1");
//小时=(时间/一个小时多少毫秒)%24
h = T.divide(BigInteger.valueOf(3600000)).mod(BigInteger.valueOf(24));
//分钟=(时间/一分钟多少毫秒)%60
m = T.divide(BigInteger.valueOf(60000)).mod(BigInteger.valueOf(60));
//秒=(时间/一秒多少毫秒)%60
s = T.divide(BigInteger.valueOf(1000)).mod(BigInteger.valueOf(60));
//如果出现小于9的要在前一位上加上0
String nh = h.compareTo(BigInteger.valueOf(9))==-1?"0"+h:""+h;
String nm = m.compareTo(BigInteger.valueOf(9))==-1?"0"+m:""+m;
String ns = s.compareTo(BigInteger.valueOf(9))==-1?"0"+s:""+s;
System.out.println(nh+":"+nm+":"+ns);
}
}
G.最小砝码
import java.util.Scanner;
public class Main{
//找规律
//公比为3的数列,
//1 3,他能表示1-4(1+3)
//1 3 9,能表示1-14(1+3+9)
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i=0;;i++) {
if((Math.pow(3,i)+1)/2>=n) {//公比为3的前i项和公式
System.out.println(i);
break;
}
}
}
}