觉得浮夸了四年,漠然发现原来是浮躁了四年!

hdu 4450(Draw Something)

Problem Description
Wangpeng is good at drawing. Now he wants to say numbers like “521” to his girlfriend through the game draw something.
Wangpeng can’t write the digit directly. So he comes up a way that drawing several squares and the total area of squares is the number he wants to say.
Input all the square Wangpeng draws, what’s the number in the picture?
 

 

Input
There are multiple test cases.
For each case, the first line contains one integer N(1≤N≤100) indicating the number of squares.
Second line contains N integers ai(1≤ai≤100)represent the side length of each square. No squares will overlap.
Input ends with N = 0.
 

 

Output
For each case, output the total area in one line.
 

 

Sample Input
4 1 2 3 4 3 3 3 3 0
 

 

Sample Output
30 27
 

 

Source
 
 
When I first  saw the problem , I coundn't believe my eyes!
Because the problem is so easy as an asia regional contest problem that I doubt my idea is right!
My idea is right because the problem is as easy as the  "a+b" problem!
View Code
#include<iostream>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0) break;
        int sum=0;
        int a;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            sum+=a*a;
        }
        cout<<sum<<endl;
    }
    return 0;
}

        

 

 
posted @ 2012-11-02 12:52  heat nan  阅读(171)  评论(0编辑  收藏  举报