DNA序列
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
while(in.hasNext()){
String str=in.nextLine();
Scanner in1=new Scanner(System.in);
int k=in.nextInt();
int max=0;
int maxIndex=0;
for(int i=0;i<str.length()-k;i++){
int count=0;
for(int j=i;j<i+k;j++) {
if (str.charAt(j) == 'G' || str.charAt(j) == 'C') {
count++;
}
}
if(count>max){
maxIndex=i;
max=count;
}
}
System.out.print(str.substring(maxIndex,maxIndex+k));
}
}
}
百万富翁问题
public class Main1 {
public static void main(String[] args) {
int rich=10*30;
System.out.print(rich+" ");
int stranger =0;
int j=1;
for(int i=0;i<30;i++){
stranger+=j;
j=j*2;
}
System.out.println(stranger);
}
}