UVa 10519 - !! Really Strange !!

题意

n个圆圈做多能划分几个区域

思路

目测法

代码

import java.math.*;
import java.io.*;
import java.util.*;

public class Main {

    static public void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            BigInteger n = in.nextBigInteger();
            if (n.compareTo(BigInteger.ZERO) == 0) {
                System.out.println("1");
                continue;
            }
            n = n.multiply(n.subtract(BigInteger.ONE)).add(BigInteger.valueOf(2));
            System.out.println(n);
        }
    }
}

你可能感兴趣的:(ACM,uva)