hdu5047 Sawtooth(推导+java大数)
来源:互联网 发布:危机公关 知乎 编辑:程序博客网 时间:2024/06/05 18:47
题目链接:点击打开链接
题意描述:给定一个无线大的平面,问给n个M型的折线最多能把平面分成几部分?
解题思路:
我们发现对于直线
1 - 2
2 - 4
3 - 7
4 - 11
5 - 16
6 - 22
7 - 29
8 - 37
而对于M型的折线
1-2
2-19
我们知道M型折线相当于4条直线
观察发现
1 - 4 2 - 8
2 11 19 37
9 18
所以规律为 8*n^2 - 7*n + 1
代码:
java.io.BufferedInputStream;import java.math.BigInteger;import java.util.Scanner;public class Main {private static Scanner cin;public static void main(String[] args){int T;cin = new Scanner(new BufferedInputStream(System.in));T=cin.nextInt();BigInteger num;for(int t=1;t<=T;++t){num=cin.nextBigInteger();BigInteger t1=num.multiply(num).multiply(BigInteger.valueOf(8));BigInteger t2=num.multiply(BigInteger.valueOf(7));BigInteger ans=t1.subtract(t2).add(BigInteger.valueOf(1));System.out.println("Case #"+t+": "+ans);}}}
0 0
- hdu5047 Sawtooth(推导+java大数)
- hdu5047 Sawtooth 规律 + JAVA大数
- HDU5047 Sawtooth 大数乘法|数学递推 Java&&C
- hdu5047(上海网赛1006)Sawtooth
- hdu5047(上海网赛1006)Sawtooth
- HDU 5047 Sawtooth (JAVA大数类)
- [Java大数+输入输出优化] hdu 5047 Sawtooth
- Hdu-5047 Sawtooth(C++大数模板)
- HDU 5047 Sawtooth(大数优化+递推公式)
- HDU5047
- HDOJ 5047 Sawtooth(Java高精度)
- 【大数问题】 HDOJ 5047 Sawtooth
- HDU-4919-数学推导加Java大数
- HDU 5047 Sawtooth(数学 公式 大数)
- HDU 5047 Sawtooth (大数模板+找规律)
- HDU 5047 Sawtooth (规律+java各种读入输出模板)
- hdu 5047 Sawtooth--2014acm上海赛区邀请赛(附java模板)
- Hdu 5047 Sawtooth(数学+大整数)
- OGG-01705 input trail file './dirdat/fc075295' is greater than the size of the file
- 从零开始学Java之出入门卫管理(二)
- C# 接口的隐式与显示实现
- C#(winform)新建项目后,调试异常终止且无错误提示问题解决办法
- hdu1166-敌兵布阵(线段树)
- hdu5047 Sawtooth(推导+java大数)
- Spring MVC入门案例(2)
- 宽度决定高度
- Spring事务配置的五种方式
- Struts DynaActionForm example
- LeetCode题解:Climbing Stairs
- 对select()参数fdset的完整理解 http://blog.csdn.net/maray/article/details/8285775
- Redis管道(Pipelining)操作
- ZOJ 1649 Rescue