洛谷P2241 统计方形(数据加强版)

参考资料:https://www.luogu.com.cn/blog/Zuoing/solution-p2241

只能说感叹大佬的强大;

不说了,手敲一边代码就这样吧,再怎么讲也不如原创讲得好;

附上代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    long long sum=0,count=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i==j)
            sum+=(n-i)*(m-j);
            else
            count+=(n-i)*(m-j);
        }
    }
    cout<<sum<<' '<<count<<endl;
    return 0;
    
}

 

posted @ 2022-02-04 02:54  江上舟摇  阅读(34)  评论(0编辑  收藏  举报