/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 440.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 320.0 KiB
#5 Accepted 1ms 324.0 KiB
#6 Accepted 1ms 324.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
/*
int res(string &s){
    int n = s.size();
    vector<int> gaps;

    int count1 = 0;
    int max1 = 0;
    bool gap = false;

    for(int i=0; i<n; i++){
        if(s[i]=='1'){
            count1++;
            max1 = max(max1,count1);
            gap = false;
        }
        else{
            if(count1>0){
                gaps.push_back(count1);
                count1 = 0;
            }
            gap = true;
        }
    }
    if(count1>0) gaps.push_back(count1);
    sort (gaps.rbegin(),gaps.rend());
    int result=0;
    for(int i=0; i<gaps.size(); i+=2){
        result+=gaps[i];
    }
    return result;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int N;
        string S;
        cin>>N>>S;
        cout<<res(S)<<endl;
    }
    return 0;
}
*/
long long res2(int H, int W){
    int mini = min(H,W);
    long long tot = 0;
    for(int k=1; k<=mini; k++){
        tot += (long long)(H-k+1)*(W-k+1);
    }
    return tot;
}
int main(){
    int H,W;
    cin>>H>>W;
    cout<<res2(H,W)<<endl;
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1121 Square Counting Challenge
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 14:56:28
Judged At
2024-11-11 02:32:02
Judged By
Score
100
Total Time
1ms
Peak Memory
532.0 KiB