答案是一个整数,类似4300的样子,结尾必然是00,不要填写任何多余的内容。
* 方法:
* 1 复制到 txt 替换字符
import java.util.Scanner;
import java.util.Scanner;public class _1 {
public static void main(String[] args) {
double sum= (180.90*0.88 +
10.25*0.65 +
56.14*0.9 +
104.65 *0.9 +
100.30 *0.88 +
297.15 *0.5 +
26.75 *0.65 +
130.62 *0.5 +
240.28 *0.58 +
270.62 *0.8 +
115.87 *0.88 +
247.34 *0.95 +
73.21 *0.9 +
101.00 *0.5 +
79.54 *0.5 +
278.44 *0.7 +
199.26 *0.5 +
12.97 *0.9 +
166.30 *0.78 +
125.50 *0.58 +
84.98 *0.9 +
113.35 *0.68 +
166.57 *0.5 +
42.56 *0.9 +
81.90 *0.95 +
131.78 *0.8 +
255.89 *0.78 +
109.17 *0.9 +
146.69 *0.68 +
139.33 *0.65 +
141.16 *0.78 +
154.74 *0.8 +
59.42 *0.8 +
85.44 *0.68 +
293.70 *0.88 +
261.79 *0.65 +
11.30 *0.88 +
268.27 *0.58 +
128.29 *0.88 +
251.03 *0.8 +
208.39 *0.75 +
128.88 *0.75 +
62.06 *0.9 +
225.87 *0.75 +
12.89 *0.75 +
34.28 *0.75 +
62.16 *0.58+
129.12 *0.5+
218.37 *0.5+
289.69 *0.8);
System.out.println(sum);
}
}
2 标题:纸牌三角形
A,2,3,4,5,6,7,8,9 共9张纸牌排成一个正三角形(A按1计算)。要求每个边的和相等。
下图就是一种排法(如有对齐问题,参看p1.png)。
A
9 6
4 8
3 7 5 2
这样的排法可能会有很多。
如果考虑旋转、镜像后相同的算同一种,一共有多少种不同的排法呢?
请你计算并提交该数字。
注意:需要提交的是一个整数,不要提交任何多余内容。
public class _2 {
static int[] first = new int[9];
static int[] s = new int[9];
static int sum = 0;
public static void main(String[] args) {
sousuo(0);
System.out.println(sum/6);
}
public static void sousuo(int code){
if(code==9){
if(s[0]+s[1]+s[3]+s[5]==s[0]+s[2]+s[4]+s[8]&&s[0]+s[1]+s[3]+s[5]==s[5]+s[6]+s[7]+s[8])
sum++;
for(int k:s)
System.out.print(" "+k);
System.out.println();
return;
}
for (int i = 0; i < 9; i++) {
if(first [i]==0){
first [i] = 1;
s[code] = i+1;
sousuo(code+1);
first [i] = 0;
}
}
}
}
/*
* 1.发现规律 /6
* 2.全排列递归
*
1 2 3
1 3 2
2 1 3
2 3 1
3 2 1
3 1 2
1 2 3
1 3 2
3 1 2
3 2 1
1 2 3
1 3 2
*/
public class _21 {
static int a=0;
public static void main(String[] args) {
int []arr = {1,2,3,4,5,6,7,8,9};
f(arr,0,9);
System.out.println(" "+a/6);
}
private static void f(int[] arr, int i, int j) {
// TODO 自动生成的方法存根
if(i==j){
if(arr[0]+arr[1]+arr[2]+arr[3]==arr[3]+arr[4]+arr[5]+arr[6]&&arr[3]+arr[4]+arr[5]+arr[6]==arr[6]+arr[7]+arr[8]+arr[1])
a++;
}
for(int k =i;k
第三题:承压计算
X星球的高科技实验室中整齐地堆放着某批珍贵金属原料。
每块金属原料的外形、尺寸完全一致,但重量不同。
金属材料被严格地堆放成金字塔形。
7
5 8
7 8 8
9 2 7 2
8 1 4 9 1
8 1 8 8 4 1
7 9 6 1 4 5 4
5 6 5 5 6 9 5 6
5 5 4 7 9 3 5 5 1
7 5 7 9 7 4 7 3 3 1
4 6 4 5 5 8 8 3 2 4 3
1 1 3 3 1 6 6 5 5 4 4 2
9 9 9 2 1 9 1 9 2 9 5 7 9
4 3 3 7 7 9 3 6 1 3 8 8 3 7
3 6 8 1 5 3 9 5 8 3 8 1 8 3 3
8 3 2 3 3 5 5 8 5 4 2 8 6 7 6 9
8 1 8 1 8 4 6 2 2 1 7 9 4 2 3 3 4
2 8 4 2 2 9 9 2 8 3 4 9 6 3 9 4 6 9
7 9 7 4 9 7 6 6 2 8 9 4 1 8 1 7 2 1 6
9 2 8 6 4 2 7 9 5 4 1 2 5 1 7 3 9 8 3 3
5 2 1 6 7 9 3 2 8 9 5 5 6 6 6 2 1 8 7 9 9
6 7 1 8 8 7 5 3 6 5 4 7 3 4 6 7 8 1 3 2 7 4
2 2 6 3 5 3 4 9 2 4 5 7 6 6 3 2 7 2 4 8 5 5 4
7 4 4 5 8 3 3 8 1 8 6 3 2 1 6 2 6 4 6 3 8 2 9 6
1 2 4 1 3 3 5 3 4 9 6 3 8 6 5 9 1 5 3 2 6 8 8 5 3
2 2 7 9 3 3 2 8 6 9 8 4 4 9 5 8 2 6 3 4 8 4 9 3 8 8
7 7 7 9 7 5 2 7 9 2 5 1 9 2 6 5 3 9 3 5 7 3 5 4 2 8 9
7 7 6 6 8 7 5 5 8 2 4 7 7 4 7 2 6 9 2 1 8 2 9 8 5 7 3 6
5 9 4 5 5 7 5 5 6 3 5 3 9 5 8 9 5 4 1 2 6 1 4 3 5 3 2 4 1
X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
其中的数字代表金属块的重量(计量单位较大)。
最下一层的X代表30台极高精度的电子秤。
假设每块原料的重量都十分精确地平均落在下方的两个金属块上,
最后,所有的金属块的重量都严格精确地平分落在最底层的电子秤上。
电子秤的计量单位很小,所以显示的数字很大。
工作人员发现,其中读数最小的电子秤的示数为:2086458231
请你推算出:读数最大的电子秤的示数为多少?
注意:需要提交的是一个整数,不要填写任何多余的内容。
要点:只要把第i行的第j个平均分给第i+1行的第j个和第i+1行的第j+1个
import java.util.Arrays;
public class _3 {
public static void main(String[] args) {
// TODO 自动生成的方法存根
double [][]arr = {
{7},
{5,8},
{7,8,8},
{9,2,7,2},
{8,1,4,9,1},
{8,1,8,8,4,1},
{7,9,6,1,4,5,4},
{5,6,5,5,6,9,5,6},
{5,5,4,7,9,3,5,5,1},
{7,5,7,9,7,4,7,3,3,1},
{4,6,4,5,5,8,8,3,2,4,3},
{1,1,3,3,1,6,6,5,5,4,4,2},
{9,9,9,2,1,9,1,9,2,9,5,7,9},
{4,3,3,7,7,9,3,6,1,3,8,8,3,7},
{3,6,8,1,5,3,9,5,8,3,8,1,8,3,3},
{8,3,2,3,3,5,5,8,5,4,2,8,6,7,6,9},
{8,1,8,1,8,4,6,2,2,1,7,9,4,2,3,3,4},
{2,8,4,2,2,9,9,2,8,3,4,9,6,3,9,4,6,9},
{7,9,7,4,9,7,6,6,2,8,9,4,1,8,1,7,2,1,6},
{9,2,8,6,4,2,7,9,5,4,1,2,5,1,7,3,9,8,3,3},
{5,2,1,6,7,9,3,2,8,9,5,5,6,6,6,2,1,8,7,9,9},
{6,7,1,8,8,7,5,3,6,5,4,7,3,4,6,7,8,1,3,2,7,4},
{2,2,6,3,5,3,4,9,2,4,5,7,6,6,3,2,7,2,4,8,5,5,4},
{7,4,4,5,8,3,3,8,1,8,6,3,2,1,6,2,6,4,6,3,8,2,9,6},
{1,2,4,1,3,3,5,3,4,9,6,3,8,6,5,9,1,5,3,2,6,8,8,5,3},
{2,2,7,9,3,3,2,8,6,9,8,4,4,9,5,8,2,6,3,4,8,4,9,3,8,8},
{7,7,7,9,7,5,2,7,9,2,5,1,9,2,6,5,3,9,3,5,7,3,5,4,2,8,9},
{7,7,6,6,8,7,5,5,8,2,4,7,7,4,7,2,6,9,2,1,8,2,9,8,5,7,3,6},
{5,9,4,5,5,7,5,5,6,3,5,3,9,5,8,9,5,4,1,2,6,1,4,3,5,3,2,4,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
for (int i=0; i
5 标题:取数位
标题:取数位
求1个整数的第k位数字有很多种方法。
以下的方法就是一种。
对于题目中的测试数据,应该打印5。
请仔细分析源码,并补充划线部分所缺少的代码。
注意:只提交缺失的代码,不要填写任何已有内容或说明性的文字。。
今年的代码填空异常简单,10min做完全部。没什么好说的。
public class Main
{
static int len(int x){
if(x<10) return 1;
return len(x/10)+1;
}
// 取x的第k位数字
static int f(int x, int k){
if(len(x)-k==0) return x%10;
return f(x/10,k); //填空
}
public static void main(String[] args)
{
int x = 23513;
//System.out.println(len(x));
System.out.println(f(x,3));
}
}
6 标题:最大公共子串
public class Main
{
static int f(String s1, String s2)
{
char[] c1 = s1.toCharArray();
char[] c2 = s2.toCharArray();
int[][] a = new int[c1.length+1][c2.length+1];
int max = 0;
for(int i=1; i max) max = a[i][j];
}
}
}
return max;
}
public static void main(String[] args){
int n = f("abcdkkk", "baabcdadabc");
System.out.println(n);
}
}
7,标题:日期问题
2004-03-02
import java.util.Scanner;
import org.junit.Test;
public class _7 {
static int monday[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner reader = new Scanner(System.in);
String s = reader.nextLine();
String [] ss = s.split("/");
int a,b,c;
a = Integer.valueOf(ss[0]);
b = Integer.valueOf(ss[1]);
c = Integer.valueOf(ss[2]);
f1(a,b,c);
f1(c,b,a);
f1(b,c,a);
}
//年月日
private static void f1(int a, int b, int c) {
boolean flag=true;
String year = "";
String mon = "";
String day = "";
year = foryear(a, year);
if(1<=b&&b<=12)
{
mon = forMon(b, mon);
}
else
flag=false;
if(flag){
if(b==2&&judgeMon(year))
{
if(c>29)
flag=false;
}
if(c>monday[b])
{
flag=false;
}
if(c==0)
{
flag=false;
}
if(flag){
day = forday(c, day);
}
}
if(flag)
System.out.println(year+"-"+mon+"-"+day);
}
private static String forday(int c, String day) {
if(c>10)
day+=c;
else
day+="0"+c;
return day;
}
private static String forMon(int b, String mon) {
if(b>=10)
mon+=b;
else
mon+="0"+b;
return mon;
}
private static String foryear(int a, String year) {
if(judgeYear(a))
year+="19"+a;
else
{
if(a>10)
year+="20"+a;
else
year+="200"+a;
}
return year;
}
@Test
private static boolean judgeMon(String year) {
int y = Integer.valueOf(year);
if(y%4==0||y%100==0&&y%400==0)
return true;
return false;
}
private static boolean judgeYear(int a) {
if(a>59)
return true;
else
return false;
}
}
8 标题:包子凑数
对于样例2,所有奇数都凑不出来,所以有无限多个。
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;
public class _8 {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner reader = new Scanner(System.in);
int num = reader.nextInt();
int []arr = new int[101];
Set setnum = new HashSet();
for(int i=0;i set1 = new LinkedHashSet();
Set set2 = new LinkedHashSet();
int []v = new int[100000];
int a = 0,b=0;
Arrays.sort(arr);
boolean ji=true,ou=true;
int count=0;
for(int i:arr){
v[i]=i;
v[i*i]=i*i;
if(ji)
{
if (i%2==1)
b=i;
}
if(ou)
{
if(i%2==0)
a=i;
}
}
dnf(arr,0,v);
for(int k=0;k<10000;k++){
v[v[k]+a] = v[k]+a;
v[v[k]+b] = v[k]+b;
}
for(int l =1; l<10000; l++){
if(v[l]==0)
count++;
}
System.out.println(count);
return 0;
}
private static void dnf(int[] arr, int i, int[] v) {
if(i==arr.length-1)
return;
for(int j=i+1; j
9 标题: 分巧克力
2
import java.util.Scanner;
public class _9 {
public static void main(String[] args) {
int n,m;
int[][]arr = null;
Scanner reader = new Scanner(System.in);
n=reader.nextInt();
m=reader.nextInt();
arr = new int[n][2];
for(int i=0;i
10,标题: k倍区间
6
import java.util.Scanner;
public class _10 {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int a = reader.nextInt();
int b = reader.nextInt();
int []arr = new int[a];
for(int i=0; i