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. java实现内部排序算法

    冒泡排序 public class BubbleSort{ public static int[] asc(int[] a){ int item; for (int i = 0; i < a.l ...

  2. WebStorm配置

    一.主题配色 主题设置方法:File -> Settings -> Appearance & Behavior -> Appearance ->Theme. webst ...

  3. fis3 scss 版本报错

    fis3 scss编译需要安装的node版本为4.x,node版本高了fis会报错.如下图所示:

  4. ehcache.xml的配置详解和示例

    <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLoc ...

  5. 基于CUDA的粒子系统的实现

    基于CUDA的粒子系统的实现 用途: 这篇文章作为代码实现的先导手册,以全局的方式概览一下粒子系统的实现大纲. 科普: 对粒子进行模拟有两种基本方法: Eulerian(grid-based) met ...

  6. Android 进程间通信——Service、Messenger

    概述 介绍绑定服务端的三种方式:同一进程绑定服务.跨进程绑定服务(Messenger).跨进程绑定服务(aidl). 重点说一下通过Messenger.Service实现的进程间通信. 详细 代码下载 ...

  7. PmExceptionController

    package main.java.com.zte.controller.system; import java.util.ArrayList; import java.util.List; impo ...

  8. 訪问可能没有定义的data (通过static类型flash.net:FileReference引用)

    今天使用Flex实现了图片预览及其上传的功能,在整个开发过程中遇到了"訪问可能没有定义的data (通过static类型flash.net:FileReference引用)"错误, ...

  9. Python的 numpy中 numpy.ravel() 和numpy.flatten()的区别和使用

    两者所要实现的功能是一致的(将多维数组降为一维), 两者的区别在于返回拷贝(copy)还是返回视图(view),numpy.flatten() 返回一份拷贝,对拷贝所做的修改不会影响(reflects ...

  10. 【JAVA】Exception in thread "main" java.lang.NoClassDefFoundError

    java新手经常会遇到这个问题. 环境变量配置正确,eclipse下可以正常编译运行,命令行下可以使用javac生成.class文件,但是在当前目录运行的时候提示: 分析报错,可以发现系统从Pack文 ...