第一次集訓個人賽 T1(簽到題)

來源:互聯網
上載者:User

標籤:des   style   blog   color   os   strong   

一、題目

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

41 2 3 433 3 30  

Sample Output

3027二、題目原始碼
#include<iostream>using namespace std;int main(){    int i,n,sum,a;    cin>>n;    while(n)    {        sum=0;        for(i=0;i<n;i++)        {            cin>>a;            sum+=a*a;        }        cout<<sum<<endl;        cin>>n;    }    return 0;}

三、心得體會

這是一道超級無敵大水題,本來是不用寫解題報告的,可是我還是必須要寫一下。因為在比賽的時候,我提交了兩次這道題都沒有AC,可是我覺得我做的挺對的,就繼續做後面的了。到最後也沒有AC.

為什嗎?

不認真讀題!我沒有注意到題目中說的 可以輸入多組資料

關於輸入輸出我還存在很大的不足,之後做題的過程中一定要注意!!

 

   

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.