UVA10519 - !! Really Strange !!(数论+高精度)
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 !!(数论+高精度)的更多相关文章
- 数论 - 高精度Fibonacci数 --- UVa 10183 : How Many Fibs ?
How many Fibs? Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := f n ...
- 2007Hanoi双塔问题
题目描述 Description 给定A.B.C三根足够长的细柱,在A柱上放有2n个中间有孔的圆盘,共有n个不同的尺寸,每个尺寸都有两个相同的圆盘,注意这两个圆盘是不加区分的(下图为n=3的情形).现 ...
- 【BZOJ1876】[SDOI2009]SuperGCD(数论,高精度)
[BZOJ1876][SDOI2009]SuperGCD(数论,高精度) 题面 BZOJ 洛谷 题解 那些说数论只会\(gcd\)的人呢?我现在连\(gcd\)都不会,谁来教教我啊? 显然\(gcd\ ...
- 数论F - Strange Way to Express Integers(不互素的的中国剩余定理)
F - Strange Way to Express Integers Time Limit:1000MS Memory Limit:131072KB 64bit IO Format: ...
- 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 ...
- UVA 10303 - How Many Trees?(数论 卡特兰数 高精度)
Problem D How Many Trees? Input: standard input Output: standard output Memory Limit: 32 MB A binary ...
- POJ 2891 Strange Way to Express Integers 中国剩余定理 数论 exgcd
http://poj.org/problem?id=2891 题意就是孙子算经里那个定理的基础描述不过换了数字和约束条件的个数…… https://blog.csdn.net/HownoneHe/ar ...
- 【poj 2891】Strange Way to Express Integers(数论--拓展欧几里德 求解同余方程组 模版题)
题意:Elina看一本刘汝佳的书(O_O*),里面介绍了一种奇怪的方法表示一个非负整数 m .也就是有 k 对 ( ai , ri ) 可以这样表示--m%ai=ri.问 m 的最小值. 解法:拓展欧 ...
- 专题[vjudge] - 数论0.1
专题[vjudge] - 数论0.1 web-address : https://cn.vjudge.net/contest/176171 A - Mathematically Hard 题意就是定义 ...
随机推荐
- solr安装使用笔记
下载 solr官方下载地址:http://lucene.apache.org/solr/ 使用 启动 solr dir/bin/solr.cmd start 停止 solr dir/bin/solr. ...
- 翻转子串(string+KMP+程序猿面试金典)
翻转子串 參与人数:1197时间限制:3秒空间限制:32768K 通过比例:35.03% 最佳记录:0 ms|8552K(来自 ) 题目描写叙述 假定我们都知道很高效的算法来检查一个单词是否为其它字符 ...
- Ubuntu apt-get方式安装Subversion
按照官方文档 http://subversion.apache.org/packages.html 使用apt-get安装方式: 1.安装Subversion: sudo apt-get instal ...
- MySQL 设置慢查询为200ms
1:查看当前版本并设置long_query_time为0.2 mysql> select version(); +------------+ | version() | +----------- ...
- @Value 和 @ConfigurationProperties 获取值的比较
1.不同点 (1)@ConfigurationProperties(prefix = "person") 功能:批量注入配置文件中的属性 SpEL:不支持表达式 JSR303数据校 ...
- ajax-原理分析
createTime--2016年9月19日13:59:11Author:Marydon参考链接 http://blog.csdn.net/csh624366188/article/details ...
- spring cloud学习地址
http://book.itmuch.com/1%20%E5%BE%AE%E6%9C%8D%E5%8A%A1%E7%AE%80%E4%BB%8B/1%20%E5%BE%AE%E6%9C%8D%E5%8 ...
- 解决python:'ascii' codec can't encode characters in position问题
今天把一个列表转换成字符串输出的时候出现了UnicodeEncodeError: 'ascii' codec can't encode characters in position 32-34: or ...
- C#:定义窗口快捷键
事情的关键是要设置Form的KeyPreview属性,然后再在KeyDown事件中检查按键. public class TEST : Form { public TEST() { Initialize ...
- 零基础学软件测试V2.0
关于本教程 本系列是在之前的基础上进行了修改更新,原来的内容显得过于简单,但都是重点,这次对于过于简单部分增加了更详细的内容. 目前国内越来越重视软件测试,人才的缺口也是比较大的,为了帮助大家快速的学 ...