hdu 4450 Draw Something

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4450


题目大意:

求出n个不重叠正方形的面积和.


题目思路:

answer=sum(a[i]*a[i]), 1<=i<=n.

面子题,全场飘球专用....


代码:

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define ls rt<<1
#define rs ls|1
#define lson l,mid,ls
#define rson mid+1,r,rs
#define middle l+r>>1
typedef pair<int,int> pii;
typedef multiset<int> mset;
typedef multiset<int>::iterator mst_it;

template <class T> T _max(T x,T y){return x>y? x:y;}
template <class T> T _min(T x,T y){return x<y? x:y;}
template <class T> void _swap(T &x,T &y){T z=x;x=y;y=z;}
template <class T> T GCD(T a,T b){for(T t;b;t=a%b,a=b,b=t);return a;}
template <class T> T LCM(T a,T b){return a/GCD(a,b)*b;}
#define clr_all(x,num) memset(x,num,sizeof(x))
#define clr(x,num,sz) memset(x,num,sizeof(x[0])*(sz+1))
#define inf 0x3F3F3F3F
#define eps (1e-9)
#define MOD 1000000007
const double pi=acos(-1.0);
const int M=500 +3;
int ts,cas=0;

int n,m;

void run(){
    int i,j,k;
    int res=0;
    while(n--){
        scanf("%d",&m);
        res+=m*m;
    }
    printf("%d\n",res);
}

void preSof(){
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preSof();
    //run();
    while(~scanf("%d",&n) && n) run();
    //for(scanf("%d",&ts),cas=1;cas<=ts;cas++) run();
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值