UVA10519 -!! Really Strange !! (Number theory + high precision)
10519 -!! Really Strange !! (Number theory + high precision)
Question Link
Give you n circles, each of which has an intersection, and the two points of the intersection are unique and cannot be handed over to other circles. How many new closed images can be generated by the n circles in the intersection of a rectangle. You will understand the chart.
Solution: Law: f (n) = f (n-1) + 2? (N-1) The last pushed f (n) = n? (N-1) + 2; (n> = 1). If the value is 0, it must be determined. N itself is a large number, and the result is also a large number.
Code:
Import java. util. *; import java. math. *; import java. io. *; public class Main {public static void main (String args []) {program cin = new program (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 )))));}}}