题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5047
题意:求n个w型折线分割平面最多区域数。。
分析:一个很不错的推论证明file:///D:/ACM%20%20Source/PDF%E4%B9%A6/%E6%8A%98%E7%BA%BF%E5%88%86%E5%89%B2%E5%B9%B3%E9%9D%A2.pdf
JAVA卡时了,需要输入输出优化。。。
687MS 代码:
import java.util.*;
import java.math.*;
import java.io.*;
public class Main
{
public static void main(String[] args) throws IOException
{
StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter cout = new PrintWriter(new BufferedOutputStream(System.out));
cin.nextToken();
int t = (int)cin.nval;
for(int ca = 1; ca <= t; ca ++)
{
cin.nextToken();
long m = (long)cin.nval;
BigInteger n = BigInteger.valueOf(m);
BigInteger one = BigInteger.ONE;
BigInteger ans = n.multiply(n.multiply(BigInteger.valueOf(8))).subtract(n.multiply(BigInteger.valueOf(7))).add(one);
cout.print("Case #"+ca+": ");
cout.println(ans);
}
cout.close();
}
}
1343MS 代码:
import java.util.*;
import java.math.*;
import java.io.*;
public class Main
{
public static void main(String[] args) throws IOException
{
Scanner cin = new Scanner(new BufferedInputStream(System.in));
PrintWriter cout = new PrintWriter(new BufferedOutputStream(System.out));
int t = cin.nextInt();
for(int ca = 1; ca <= t; ca ++)
{
BigInteger n = cin.nextBigInteger();
BigInteger one = BigInteger.ONE;
BigInteger ans = n.multiply(n.multiply(BigInteger.valueOf(8))).subtract(n.multiply(BigInteger.valueOf(7))).add(one);
cout.print("Case #"+ca+": ");
cout.println(ans);
}
cin.close();
cout.close();
}
}