ACM-Draw Something

描述

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?

输入
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

输出
For each case, output the total area in one line
样例输入
4
1 2 3 4
3
3 3 3
0
样例输出
30
27

代码:

01.#include<iostream>

02.using
namespace std;

03.int
main()

04.{

05.int
t,i;

06.while(cin>>t,t)

07.{

08.int
sum=0,n,a[100]={0};

09.

10.for(i=0;i<t;i++)

11.{

12.cin>>n;

13.a[i] = n;

14.}

15.for(i = 0;i<t;i++)

16.sum+=a[i]*a[i];

17.cout<<sum<<endl;

18.}

19.}

时间: 2024-08-06 22:55:11

ACM-Draw Something的相关文章

IEEE/ACM International Conference on Advances in Social Network Analysis and Mining (ASONAM) 2014 Industry Track Call for Papers

IEEE/ACM International Conference on Advances in Social Network Analysis and Mining (ASONAM) 2014 Industry Track Call for Papers Beijing China August 17-20, 2014Home Page: www.asonam2014.org Full paper/short paper/extended abstract submission deadlin

IEEE/ACM ASONAM 2014 Industry Track Call for Papers

IEEE/ACM International Conference on Advances in Social Network Analysis and Mining (ASONAM) 2014 Industry Track Call for Papers * Apologies if you received multiple copies of this CFP * Beijing China August 17-20, 2014Home Page: www.asonam2014.org F

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 =

2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分

I Count Two Three Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 782    Accepted Submission(s): 406 Problem Description I will show you the most popular board game in the Shanghai Ingress Resis

[ACM] HDU 1400 Mondriaan&#39;s Dream (状态压缩,长2宽1长方形铺满)

Mondriaan's Dream Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 783    Accepted Submission(s): 506 Problem Description Squares and rectangles fascinated the famous Dutch painter Piet Mondri

[ACM] HDU 1400 Mondriaan&amp;#39;s Dream (状态压缩,长2宽1长方形铺满)

Mondriaan's Dream Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 783    Accepted Submission(s): 506 Problem Description Squares and rectangles fascinated the famous Dutch painter Piet Mondri

2016 ACM/ICPC亚洲区大连站-重现赛 解题报告

任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5979 按AC顺序: I - Convex Time limit    1000 ms Memory limit 65536 kB OS Windows We have a special convex that all points have the same distance to origin point. As you know we can get N segments after linki

移动端上传照片 预览+draw on Canvas demo(解决iOS等设备照片旋转90度的bug)

背景: 本人的一个移动端H5项目,需求如下: 手机相册选取或拍摄照片后在页面上预览 然后绘制在canvas画布上. 这里,我们先看一个demo(http://jsfiddle.net/q3011893/83qfqpk8/embedded/) 操作步骤: 1.点击选择文件,拍摄一张照片,此时"预览:"文字下会显示你刚才拍摄的照片: 2.再点击"draw on Canvas",该按钮下的画布会绘制你刚才拍摄的照片. 正常的结果: 正文: 让input file支持拍照+

《ACM/ICPC 算法训练教程》读书笔记一之数据结构(堆)

书籍简评:<ACM/ICPC 算法训练教程>这本书是余立功主编的,代码来自南京理工大学ACM集训队代码库,所以小编看过之后发现确实很实用,适合集训的时候刷题啊~~,当时是听了集训队final的意见买的,感觉还是不错滴. 相对于其他ACM书籍来说,当然如书名所言,这是一本算法训练书,有着大量的算法实战题目和代码,尽管小编还是发现了些许错误= =,有部分注释的语序习惯也有点不太合我的胃口.实战题目较多是比较水的题,但也正因此才能帮助不少新手入门,个人认为还是一本不错的算法书,当然自学还是需要下不少

acm常见算法及例题

转自:http://blog.csdn.net/hengjie2009/article/details/7540135 acm常见算法及例题 初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法