/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 1ms 540.0 KiB
#4 Wrong Answer 1ms 540.0 KiB
#5 Wrong Answer 604ms 576.0 KiB
#6 Accepted 603ms 556.0 KiB
#7 Accepted 603ms 552.0 KiB
#8 Wrong Answer 201ms 548.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:42
Judged At
2024-05-07 02:36:42
Judged By
Score
45
Total Time
604ms
Peak Memory
576.0 KiB