CCF题集测试页面
报数——Java版
package 蓝桥杯;
import java.util.Scanner;
public class P1_报数1 {
public static void main(String[] args) {
Scanner reader=new Scanner(System.in);
int n=reader.nextInt();
int number=0;
int count=0;
int[] player= {0,0,0,0,0};
while(n>count) {
number++;
if(number%7==0||number%10==7||(number/10)%10==7) {
if(number%4==1) {
player[1]+=1;
}
else if(number%4==2) {
player[2]+=1;
}
else if(number%4==3) {
player[3]+=1;
}
else if(number%4==0) {
player[4]+=1;
}
}
else count++;
}
for(int i=1;i<=4;i++) {
System.out.println(player[i]);
}
}
}
小明种苹果——Java版
package 蓝桥杯;
import java.util.Scanner;
class appletree{
int startnum=0;
int num=0;
}
public class P2_小明种苹果 {
public static void main(String[] args) {
Scanner reader=new Scanner(System.in);
int n=reader.nextInt();
int m=reader.nextInt();
int mbake=m;
appletree[] tree =new appletree[1000000];
int j=0;
int T=0,K=0,P=-1;
while(n!=0) {
appletree t=new appletree();
t.startnum=reader.nextInt();
T+=t.startnum;
while(mbake>0) {
t.num-=reader.nextInt();
mbake--;
}
T-=t.num;
tree[j]=t;
if(t.num>P) {
P=t.num;
K=j+1;
}
n--;
j++;
mbake=m;
}
System.out.println(T+" "+K+" "+P);
reader.close();
}
}