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

 1 #include <iostream>
 2 #include <cmath>
 3 using namespace std;
 4
 5 int N;
 6 int i;
 7 int side[300];
 8 int main()
 9 {
10     while(cin >> N)
11     {
12         int sum = 0;
13         if(N == 0) return 0;
14         else
15         {
16             for(i = 0;i < N;i++)
17             {
18                 cin >> side[i];
19                 sum = side[i] * side[i] +sum;
20             }
21             cout << sum <<endl;
22         }
23     }
24     return 0;
25 }

HDU 4450 Draw Something,布布扣,bubuko.com

时间: 2024-08-04 19:15:43

HDU 4450 Draw Something的相关文章

hdu 4056 Draw a Mess(数据结构-并查集)

Draw a Mess Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 864    Accepted Submission(s): 180 Problem Description It's graduated season, every students should leave something on the wall, so.

所谓的日常 #1 - 宴桃園豪傑三結義 斬黃巾英雄首立功

div.2 CodeForces 467A George and Accommodation 给定n(<= 100)对(pi,qi),问有多少个i满足qi - pi >= 2. 照着题意写就可以了,算是给大家道题练练手啦. 1 #include <stdio.h> 2 3 int main() { 4 int n; 5 scanf("%d",&n); 6 int answer = 0; 7 for (int i = 0; i < n; ++ i)

暑假集训-合训第9场

ID Origin Title   8 / 22 Problem A HDU 4358 Boring counting 35 / 52 Problem B HDU 4359 Easy Tree DP? 31 / 79 Problem C HDU 4362 Dragon Ball   1 / 2 Problem D HDU 4363 Draw and paint 18 / 56 Problem E HDU 4365 Palindrome graph   3 / 17 Problem F HDU 4

CSU-ACM2014暑假集训基础组训练赛(1) 解题报告

•Problem A HDU 4450                 水题,签到题 水题..没啥好说的.给大家签到用的. 1 #include <cstdio> 2 int main(){ 3 int n,a,ans; 4 while(scanf("%d",&n),n){ 5 ans = 0; 6 for(int i = 0;i < n;i++){ 7 scanf("%d",&a); 8 ans += a*a; 9 } 10 pr

hdu 4723 How Long Do You Have to Draw(贪心)

How Long Do You Have to Draw Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 277    Accepted Submission(s): 110 Problem Description There are two horizontal lines on the XoY plane. One is y1 =

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

HDU 5319

Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 816    Accepted Submission(s): 376 Problem Description Mr. Hdu is an painter, as we all know, painters need ideas to innovate , one day,

HDU 5319多校 模拟

Problem Description Mr. Hdu is an painter, as we all know, painters need ideas to innovate , one day, he got stuck in rut and the ideas dry up, he took out a drawing board and began to draw casually. Imagine the board is a rectangle, consists of seve

HDU - 4974 A simple water problem

Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or 1 for each competitor and add it to the total score