Luogu P2241 Statistical Square (Data Enhanced Edition) Problem Solution

topic portal

Said to be an enhanced version, in fact, you can paste the code of the chessboard question (be careful to open long long):

#include<bits/stdc++.h>
using namespace std;
long long n,m,z=0,c;
int main(){
    cin>>n>>m;
    for(long long i=0;i<(n>m?m:n);++i) z+=(n-i)*(m-i);
    c=(1+n)*(1+m)*n*m/4-z;
    cout<<z<<" "<<c<<endl;
    return 0;
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325182840&siteId=291194637