/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 516.0 KiB
#2 Wrong Answer 78ms 440.0 KiB
#3 Time Exceeded ≥1097ms ≥332.0 KiB
#4 Time Exceeded ≥1009ms ≥332.0 KiB
#5 Time Exceeded ≥1032ms ≥284.0 KiB
#6 Time Exceeded ≥1018ms ≥284.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-10-03 13:07:33
Judged By
Score
10
Total Time
≥1097ms
Peak Memory
≥516.0 KiB