/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 58ms 440.0 KiB
#3 Time Exceeded ≥1080ms ≥432.0 KiB

Code

#include <stdio.h>
#include <math.h>

int count_valid_pairs(int A, int B) {

long long total_pairs = (long long)A * B;
long long count_perfect_square_pairs = 0;
for (int i = 1; i <= A; i++) {
        for (int j = 1; j <= B; j++) {
            long long product = (long long)i * j;
            long long root = (long long)sqrt(product);
            if (root * root == product) {
                count_perfect_square_pairs++;
            }
        }
    }
return total_pairs - count_perfect_square_pairs;
}

int main() {
    int T;
scanf("%d", &T);
    
    while (T--) {
        int A, B;
        scanf("%d %d", &A, &B);
printf("%lld\n", count_valid_pairs(A, B));
    }
    
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1075 GCD not equal LCM
Contest
Brain Booster #5
Language
C99 (GCC 13.2.0)
Submit At
2024-09-05 16:26:38
Judged At
2024-11-11 03:00:39
Judged By
Score
10
Total Time
≥1080ms
Peak Memory
≥440.0 KiB