hdu 3083 The Mystery of Triangle

//感谢 整数序列网 的支持

import java.io.*;

import java.util.*;
import
java.math.*;
/**
*
* @author Administrator
*/

public class
Main
{


    /**
     * @param args the command line arguments
     */

    public static
void main(String[] args)
    {

        // TODO code application logic here
        Scanner cin = new Scanner(System.in);
        BigInteger
a, b;
        BigInteger
one = new BigInteger("1");
        BigInteger
two = new BigInteger("2");
        BigInteger
eight = new BigInteger("8");
        BigInteger
num = new BigInteger("20091226");
        while
(cin.hasNextBigInteger())
        {

            a = cin.nextBigInteger();
            b = a.multiply(a.add(two)).multiply(a.multiply(two).add(one)).divide(eight).mod(num);
            System
.out.println("Triangle: " + b);
            b = a.multiply(a.add(two)).multiply(a.multiply(two).subtract(one)).divide(eight).mod(num);
            System
.out.println("Diamond: " + b);
            a = a.add(one);
            b = a.multiply(a.add(one)).multiply(a.subtract(one)).multiply(a.subtract(two)).divide(eight).mod(num);
            System
.out.println("Parallelogram: " + b);
        }
    }
}

posted on 2009-12-31 21:27  ZAFU_VA  阅读(238)  评论(0编辑  收藏  举报

导航