B. Cutting Carrot

题目地址:http://codeforces.com/contest/794/problem/B

思路:三角函数的简单应用,三角函数里面的参数是弧度制

AC代码:

import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);
while (in.hasNextInt()) {
long n = in.nextLong();
long h = in.nextLong();
for (int i=1; i<n; i++) {
double x = Math.sqrt(h * h * i * 1.0 / n);
DecimalFormat df = new DecimalFormat("0.000000000000");
System.out.print(df.format(x) + " ");
}
System.out.println();
}
}

}

C. Naming Company

题目地址:http://codeforces.com/contest/794/problem/C

思路:

错误代码:

import java.util.Arrays;
import java.util.Scanner;

public class Main {

static char[] first = new char[300010];
static char[] second = new char[300010];

public static void main(String[] args) {

Scanner in = new Scanner(System.in);
while (in.hasNext()) {
first = in.next().toCharArray();
second = in.next().toCharArray();
//对0到first.length的数组进行排序,包括0不包括first.length
Arrays.sort(first,0,first.length);
Arrays.sort(second,0,second.length);
String str = "";
int len = first.length;
int i;
for (i=0; i<len/2; i++) {
str += first[i];
str += second[len-1-i];
}
if ((len & 1) == 1)
str += first[i];
System.out.println(str);
}
}

}


我这个思路是Oleg每次在剩余位置的最左边放入他目前最小的,而lgor每次在剩余位置的最右边放入最大的

给一个例子

cbxz
aaaa

正确答案是

abac

而我的是

baca