/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 5ms 532.0 KiB
#2 Accepted 5ms 532.0 KiB
#3 Accepted 5ms 568.0 KiB
#4 Accepted 31ms 532.0 KiB
#5 Accepted 193ms 576.0 KiB
#6 Time Exceeded ≥1599ms ≥532.0 KiB
#7 Accepted 3ms 532.0 KiB
#8 Accepted 10ms 580.0 KiB
#9 Accepted 1185ms 624.0 KiB
#10 Time Exceeded ≥1598ms ≥636.0 KiB

Code

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

  //  freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

    int t;
    cin >> t;

    while(t-->0){
        int x, k;
        cin >> x >> k;
        vector<pair<int,int> > vec;
        for(int i = 2; i * i <= x; ++i){
            if(x % i == 0){
                int cnt = 0;
                while(x % i == 0){
                    ++cnt;
                    x /= i;
                }
                vec.push_back({i, cnt});
            }
        }
        if(x > 1)vec.push_back({x, 1});
        for(int i = 1; i <= k; ++i){
            if(i & 1){
                vec[0].second++;
            }else{
                vec[vec.size() - 1].second--;
                if(vec[vec.size() - 1].second == 0){
                    vec.erase(vec.begin() + vec.size() - 1);
                    if(vec.size() == 1){
                        if(k & 1)vec[0].second++;
                        break;
                    }
                }
            }
        }
        x = 1;
        for(int i = 0; i < vec.size(); ++i){
            for(int j = 0; j < vec[i].second; ++j){
                x *= vec[i].first;
            }
        }
        cout << x << '\n';
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1194 D. Roy and Prime Game
Contest
Happy New Year 2026
Language
C++11 (G++ 13.2.0)
Submit At
2026-01-06 15:46:13
Judged At
2026-01-06 15:46:13
Judged By
Score
65
Total Time
≥1599ms
Peak Memory
≥636.0 KiB