Draw Something

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 3698    Accepted Submission(s): 3089

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
2012 Asia JinHua Regional Contest

Regionals 2012 >> Asia - Jinhua


问题链接:UVALive6336 HDU4450 Draw Something

问题简述:(略)

问题分析:(略)

程序说明:这里给出两个版本的程序。

题记:(略)

参考链接:(略)

AC的C语言程序如下:

/* UVALive6336 HDU4450 Draw Something */#include <stdio.h>int main()
{int n;while (scanf("%d", &n) != EOF) {if(n == 0)break;int sum = 0;for(int i=0; i<n; i++) {int x;scanf ("%d", &x);sum += x * x;}printf ("%d\n", sum);}return 0;
}

AC的C++语言程序如下:

/* UVALive6336 HDU4450 Draw Something */#include <iostream>
#include <stdio.h>using namespace std;int main()
{int n, m, sum;while (scanf("%d", &n) != EOF && n) {sum = 0;while(n--) {scanf ("%d", &m);sum += m * m;}printf ("%d\n", sum);}return 0;
}

UVALive6336 HDU4450 Draw Something【水题】相关推荐

  1. hdoj 4450 Draw Something 水题

    Draw Something Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...

  2. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  3. HDU2673-shǎ崽(水题)

    如果不能够直接秒杀的题,就不算水题.又应证了那句话,有时候,如果在水题上卡住,那么此题对于你来说,也就不算是水题了额~~ 刚睡醒,迷迷糊糊. 题目的意思很简单,求一个最大的,再求一个最小的.几乎是什么 ...

  4. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  5. 图论刷水题记录(一)(最短路-----dijkstra算法)

    最近实在不知道干些什么,感觉自己除了水题什么都不会做,算了去刷一刷图论的水题吧本来想合起来一起发,想了想太长的话以后看起来也不方便,题目所以今天晚上就先发了dij部分,由上到下由易变难. 1.POJ ...

  6. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  7. HDU2568 前进【水题】

    前进 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  8. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

  9. NUC1312 Sum【水题+数学题】

    Sum 时间限制: 1000ms 内存限制: 65536KB 通过次数: 1总提交次数: 1 问题描述 认为自然数是从1-N.将每个数和+或-联系起来,然后计算这个表达式的值我们得到一个和S.这个问题 ...

最新文章

  1. 漫画:什么是 “设计模式” ?
  2. Spring Cloud Config-Git后端
  3. Spring Boot微服务中Chaos Monkey的应用
  4. 非空约束对数据更新的影响
  5. 异常处理---SpringMVC学习笔记(十)
  6. mysql卸载安装视频_MYSQL安装与卸载(一)
  7. day-05 python函数
  8. mysql自左连接最大值_mysql左连接自连接例子
  9. ContentProvider中gettype() 和MIME类型的理解
  10. 【python】isinstance可以接收多个类型,hasattr,getattr,setattr
  11. GDI+学习及代码总结之------画刷Brush .
  12. oracle改字符集sjis,MySQL字符集专题(字符集,校对,乱码)_MySQL
  13. centos安装aria2c_CentOS安装aria2+yaaw实现离线下载
  14. 好想与你天长地久,共度岁月
  15. 欢迎高校选修云创大数据免费在线直播课!
  16. SwitchBox系列 - 介绍
  17. netty内存泄露检测
  18. 简单实现目标箭头导航
  19. ArcMap打开ArcToolbox异常闪退解决办法
  20. 爱思服务器shsh文件类型,爱思助手无法提取SHSH降级iOS6.1.2固件指南

热门文章

  1. Python自省(反射)指南 1
  2. AIR3.0针对移动设备的高性能渲染方案
  3. 【转载】RPG模式研究——即时制与回合制战斗对比
  4. as3与php交互实现总结
  5. shared_ptr四宗罪
  6. cas client 更新ticket_cas sso单点登录系列6_cas单点登录防止登出退出后刷新后退ticket失效报500错...
  7. 详解:hive启动hiveserver2连JDBC报错:Could not open client transport with JDBC Uri 解决方案
  8. Hive 与 RDBMS的区别
  9. 数据挖掘:模型选择——XGBoost与LightBGM
  10. shell脚本特殊变量与变量子串相关知识