/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 328.0 KiB
#3 Wrong Answer 1ms 540.0 KiB
#4 Wrong Answer 1ms 540.0 KiB
#5 Wrong Answer 607ms 820.0 KiB
#6 Accepted 604ms 548.0 KiB
#7 Accepted 628ms 816.0 KiB
#8 Wrong Answer 246ms 572.0 KiB

Code

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int T;
    cin >> T;

    while (T--) {
        int N;
        cin >> N;

        int maxPartitions = 1; // Initialize with 1 partition

        // Iterate from 2 to sqrt(N)
        for (int i = 2; i * i <= N; i++) {
            // Check if N is divisible by i
            if (N % i == 0) {
                int diff = N / i; // Calculate the difference for each subarray of length i

                // Check if the difference is the same for all subarrays
                if (N % diff == 0) {
                    maxPartitions = max(maxPartitions, N / diff);
                }
            }
        }

        cout << maxPartitions << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1052 Yet Another Array Partition
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-07 02:36:39
Judged At
2024-05-07 02:36:39
Judged By
Score
45
Total Time
628ms
Peak Memory
820.0 KiB