10519 - !! Really Strange !!(数论+高精度)

option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1460" style="">题目链接

题目大意:给你n个圆,每两个圆都有相交的部分,而且相交的两个点都唯一的,不能再和别的圆交于这点。

问这样在一个矩形里的相交的n个圆能够产生多少个新的封闭图形。

看图会明确的。

解题思路:规律:f(n) = f(n - 1) + 2
∗(n
- 1) 最后推的 f(n) = n

(n - 1) + 2; (n >= 1), 0的时候要特判。n本身就是个大数,结果也是个大数。

代码:

import java.util.*;
import java.math.*;
import java.io.*; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in);
BigInteger n;
while (cin.hasNext()) { n = cin.nextBigInteger();
if (n.equals(BigInteger.ZERO))
System.out.println(1);
else
System.out.println(BigInteger.valueOf(2).add(n.multiply(n.subtract(BigInteger.valueOf(1)))));
}
}
}

UVA10519 - !! Really Strange !!(数论+高精度)的更多相关文章

  1. 数论 - 高精度Fibonacci数 --- UVa 10183 : How Many Fibs ?

    How many Fibs? Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := f n ...

  2. 2007Hanoi双塔问题

    题目描述 Description 给定A.B.C三根足够长的细柱,在A柱上放有2n个中间有孔的圆盘,共有n个不同的尺寸,每个尺寸都有两个相同的圆盘,注意这两个圆盘是不加区分的(下图为n=3的情形).现 ...

  3. 【BZOJ1876】[SDOI2009]SuperGCD(数论,高精度)

    [BZOJ1876][SDOI2009]SuperGCD(数论,高精度) 题面 BZOJ 洛谷 题解 那些说数论只会\(gcd\)的人呢?我现在连\(gcd\)都不会,谁来教教我啊? 显然\(gcd\ ...

  4. 数论F - Strange Way to Express Integers(不互素的的中国剩余定理)

    F - Strange Way to Express Integers Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format: ...

  5. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

  6. UVA 10303 - How Many Trees?(数论 卡特兰数 高精度)

    Problem D How Many Trees? Input: standard input Output: standard output Memory Limit: 32 MB A binary ...

  7. POJ 2891 Strange Way to Express Integers 中国剩余定理 数论 exgcd

    http://poj.org/problem?id=2891 题意就是孙子算经里那个定理的基础描述不过换了数字和约束条件的个数…… https://blog.csdn.net/HownoneHe/ar ...

  8. 【poj 2891】Strange Way to Express Integers(数论--拓展欧几里德 求解同余方程组 模版题)

    题意:Elina看一本刘汝佳的书(O_O*),里面介绍了一种奇怪的方法表示一个非负整数 m .也就是有 k 对 ( ai , ri ) 可以这样表示--m%ai=ri.问 m 的最小值. 解法:拓展欧 ...

  9. 专题[vjudge] - 数论0.1

    专题[vjudge] - 数论0.1 web-address : https://cn.vjudge.net/contest/176171 A - Mathematically Hard 题意就是定义 ...

随机推荐

  1. 在 linux 下使用 CMake 构建应用程序

    学习cmake http://xwz.me/wiki/doku.php?id=cmake 碰到的一些问题: 1.You have changed variables that require your ...

  2. Mysql(一)安装

    一.下载 下载地址:http://www.mysql.com/downloads/ 二.安装 解压 双击安装 下一步,选择NO, 下一步,选择, 按需求选择,这时选择developer default ...

  3. html5开放资料

    http://www.cnblogs.com/tim-li/archive/2012/08/06/2580252.html KineticJS教程(12) 摘要: KineticJS教程(12) 作者 ...

  4. C语言变量的声明位置

    标准C里面必须放在代码前面,否则出错: C++里面不一定要放在最前面,用的时候声明也不迟: 所以要看具体的编译环境,如果是C的话必须放在最前,C++就不用:一般.c后缀的是C文件,按C来编译:.cpp ...

  5. TP3.2 APP_DEBUG=false关闭调试后访问不了。页面错误!请稍后再试~

    在APP_DEBUG=true时是没问题的,在APP_DEBUG=false时才会出现找不到模板的问题.  经过排查可能是模板文件找不到问题,之前是这么写的. 改为这个就好了. ----------- ...

  6. cordova 命令行打包apk

    Cordova 打包 Android release app 过程详解: 1.全局安装Cordova CLI: npm install -g cordova 2.创建项目: cordova creat ...

  7. 原创Oracle数据泵导出/导入(expdp/impdp)

    //创建目录 create Or Replace directory dpdata1 as 'd:\test\dump'; //赋予读写权限 grant read,write on directory ...

  8. word技巧-文本转化表格

    工作中不断学习,总能得到一点点成就感! 样例:

  9. HDUOJ -----1864 最大报销额(动态规划)

    最大报销额 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  10. HDUOJ-4104 Discount

    Discount Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...