ACM (TJU) : 2800


// http://acm.tju.edu.cn/toj/showp2800.html

#include <stdio.h>

int main ()
{
    int dataset;
    scanf ("%d", &dataset);

    while ( dataset-- ) {
        int n;
        scanf ("%d", &n);

        int mid_point = (n * n * n) / n;
        int start;
        int finish;

        if ( n % 2 ) {
            start = mid_point;
            finish = mid_point;

            for ( int i = 0; i < n / 2; i++ ) {
                start -= 2;
                finish += 2;
            }
        }

        else {

            start = mid_point - 1;
            finish = mid_point + 1;

            for ( int i = 1; i < n / 2; i++ ) {
                start -= 2;
                finish += 2;
            }
        }

        printf ("%d %d\n", start, finish);
    }

    return 0;
}
Advertisements

One thought on “ACM (TJU) : 2800

  1. 10
    1
    1 1
    2
    3 5
    4
    13 19
    5
    21 29
    6
    31 41
    7
    43 55
    8
    57 71
    9
    73 89
    1000
    999001 1000999
    999
    997003 998999
    Press any key to continue.
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s