Acm_icpc network competition site 6: Shanghai Division (my heart is dead)

Source: Internet
Author: User

After the last stop, I had to admit that I was not able to qualify, and finally I ended the three questions. In the 380 ranking, I had to admit that I couldn't do it. I always felt that I had done it for a few months, then I made various excuses for my weakness. If I can't do it, I can't do it. I don't have an excuse. I have to work harder in the future. No more nonsense. Fighting!

1006:

Sawtooth Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/65536 K (Java/Others)
Total submission (s): 466 accepted submission (s): 152


Problem descriptionthink about a plane:

● One straight line can divide a plane into two regions.
● Two lines can divide a plane into at most four regions.
● Three lines can divide a plane into at most seven regions.
● And so on...

Now we have some figure constructed with two parallel rays in the same direction, joined by two straight segments. it looks like a character "M ". you are given n such "M" S. what is the maximum number of regions that these "M" s can divide a plane?

 
Inputthe first line of the input is t (1 ≤ T ≤ 100000), which stands for the number of test cases you need to solve.

Each case contains one single non-negative integer, indicating number of "M" S. (0 ≤ n ≤0 ≤ 1012)
Outputfor each test case, print a line "Case # T:" (without quotes, t means the index of the test case) at the beginning. then an integer that is the maximum number of regions n the "M" figures can divide.
Sample Input
212
 
Sample output
Case #1: 2 case #2: 19 when the number n + 1 "M" is increased by a recurrence + large number, the intersection can be at most 16 N, so the number of regions added is 16 n + 1; F (n + 1)-f (n) = 16 * n + 1; F (1) = 2; F (n) = N * (8 * N-7) + 1; then you can directly access biginteger. Then, the tragedy is that at that time, I did not enter the optimization results of Java .. Finally, the Code for JAVA input and output optimization is very simple on the array simulated by teammates ~
Import Java. io. *; import Java. util. *; import Java. math. biginteger; public class Hello {public static void main (string [] ARGs) throws ioexception {streamtokenizer in = new streamtokenizer (New bufferedreader (New inputstreamreader (system. in); printwriter out = new printwriter (New outputstreamwriter (system. out); int T, CAS = 1; biginteger N, A, B, C; In. nexttoken (); t = (INT) in. nval; For (INT I = 1; I <= T; I ++) {In. nexttoken (); long x = (long) in. nval; n = biginteger. valueof (x); A = new biginteger ("8"); B = new biginteger ("7"); C = new biginteger ("1"); biginteger ans =. multiply (n); ans = ans. subtract (B); ans = ans. multiply (n); ans = ans. add (c); out. println ("case #" + CAS + ":" + ans); CAS ++;} Out. flush (); // refresh the buffer (required) out. close ();}}

1009: divided landTime Limit: 8000/4000 MS (Java/others) memory limit: 65536/65536 K (Java/Others)
Total submission (s): 133 accepted submission (s): 69


Problem descriptionit's time to fight the local despots and redistribute the land. there is a rectangular piece of land granted from the Government, whose length and width are both in binary form. as the mayor, you must segment the land into multiple squares of equal size for the specified agers. what are required is there must be no any waste and each single segmented square land has as large area as possible. the width of the segmented square land is also binary.
Inputthe first line of the input is t (1 ≤ T ≤ 100), which stands for the number of test cases you need to solve.

Each case contains two binary number represents the length L and the width W of given land. (0 <L, W ≤21000)
Outputfor each test case, print a line "Case # T:" (without quotes, t means the index of the test case) at the beginning. then one number means the largest width of land that can be divided from input data. and it will be show in binary. do not have any useless number or space.
Sample Input
310 100100 11010010 1100
 
Sample output
Case #1: 10 case #2: 10 case #3: 110 binary evaluate, the maximum common divisor of B is still biginteger. Because I didn't know the biginteger binary conversion at the beginning, CHP was simulated for a long time and I didn't know it well. Then I used Java 10 lines to solve it.
import java.io.*;import java.util.*;import java.math.*;import java.text.*;public class Main {    public static void main(String[] args) {        Scanner in=new Scanner(System.in);        String a,b;int t,cas=1;        t=in.nextInt();        for(int i=0;i<t;i++){            a=in.next();            b=in.next();            BigInteger x=new BigInteger(a,2);            BigInteger y=new BigInteger(b,2);            System.out.print("Case #"+cas+": ");cas++;            System.out.println(x.gcd(y).toString(2));        }            }}

1012: The sum of cubeTime Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 181 accepted submission (s): 114


Problem descriptiona range is given, the begin and the end are both integers. You shoshould sum the cube of all the integers in the range.
Inputthe first line of the input is t (1 <= T <= 1000), which stands for the number of test cases you need to solve.
Each case of input is a pair of integer a, B (0 <A <= B <= 10000), representing the range [a, B].
Outputfor each test case, print a line "Case # T:" (without quotes, t means the index of the test case) at the beginning. then output the answer-sum the cube of all the integers in the range.
Sample Input
21 32 5
 
Sample output
Case #1: 36 case #2: 224 water question not explained
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <string>using namespace std;#define LL long longint main(){    LL a,b;int t,cas=1;    cin>>t;    while(t--)    {        cin>>a>>b;        LL ans=0;        for(LL i=a;i<=b;i++)            ans+=(i*i*i);        cout<<"Case #"<<cas++<<": "<<ans<<endl;    }    return 0;}



Acm_icpc network competition site 6: Shanghai Division (my heart is dead)

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.