UVa 10489-boxes of Chocolates

Source: Internet
Author: User

Title: There is a box of B, not a box has A1 a small box, each small box inside there are A2 a smaller box, ... ;

The smallest box has AK chocolate, asking for the remainder of the chocolate to be given to n individuals.

Analysis: Simulation, large integer multiplication, remainder operation. Solve a large number of classes directly using Java.

Description: (⊙_⊙) class name if Main.

Import Java.util.Scanner;  Import Java.math.BigInteger;    Class main{public      static void Main (string[] args) {          Scanner cin = new Scanner (system.in);          int T = Cin.nextint ();          int N, B, K;                while (T--> 0) {              N = Cin.nextint ();              B = Cin.nextint ();              BigInteger ans = biginteger.valueof (0);              while (B--> 0) {                  K = Cin.nextint ();                  BigInteger tmp = biginteger.valueof (1);                  while (K--> 0) {                    tmp = tmp.multiply (biginteger.valueof (Cin.nextint ()));                  }                  Ans = ans.add (tmp);              }                          System.out.println ((Ans.remainder (biginteger.valueof (N))). ToString ());}}}  


UVa 10489-boxes of chocolates

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.