/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 13ms 3.062 MiB
#2 Accepted 14ms 3.09 MiB
#3 Accepted 14ms 2.926 MiB
#4 Accepted 36ms 3.027 MiB
#5 Accepted 17ms 2.961 MiB
#6 Accepted 13ms 3.113 MiB

Code

def count_square_subgrids(H, W):
    max_square_size = min(H, W)
    total_count = 0
    
    for n in range(1, max_square_size + 1):
        subgrids_count = (H - n + 1) * (W - n + 1)
        total_count += subgrids_count
    
    return total_count

H, W = map(int,input().split())
print(count_square_subgrids(H, W))

Information

Submit By
Type
Submission
Problem
P1121 Square Counting Challenge
Contest
Brain Booster #7
Language
Python 3 (Python 3.12.3)
Submit At
2024-11-05 14:44:37
Judged At
2024-11-05 14:44:37
Judged By
Score
100
Total Time
36ms
Peak Memory
3.113 MiB