/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 2ms 324.0 KiB
#3 Wrong Answer 2ms 512.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-11-11 03:31:11
Judged By
Score
5
Total Time
2ms
Peak Memory
512.0 KiB