Demo entry 6642790

pp

   

Submitted by ppp on Sep 25, 2017 at 15:23
Language: C++. Code size: 494 Bytes.

//找规律的题,首先我们要求一行中有多少个矩形和一列中有多少个矩形,然后将矩形的个数乘起来  
//就是矩形的总数!   
#include <stdio.h>  
int main()  
{  
     __int64 n,m;  
    while(scanf("%I64d%I64d",&n,&m)!=EOF)  
    {  
         __int64 s1=0;  
        for(int i=1;i<=n;i++)  
        {  
            s1+=i;  
        }  
         __int64 s2=0;  
        for(int j=1;j<=m;j++)  
        {  
            s2+=j;  
        }  
        printf("%I64d\n",s1*s2);//如果不是long long型的数据就会出现数据溢出,要特别注意!   
    }  
    return 0;  
}  

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).