UVA10519 -!! Really Strange !! (Number theory + high precision)

Source: Internet
Author: User

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 )))));}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.