Submission #1087062

# Submission time Handle Problem Language Result Execution time Memory
1087062 2024-09-12T07:07:43 Z Dennis_Jason Intercastellar (JOI22_ho_t1) C++14
25 / 100
194 ms 25272 KB
#include <bitset>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <system_error>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define pb push_back
#define MOD 1000000007
#define NMAX 200001
#define MAX 100000
#define nl '\n'
#define pii1 pair<int, pair<int,int>>  (1,(1,2));
#define pii pair<int,int>
#define tpl tuple<int,int,int>
#define int long long
using namespace std;
ifstream fin("data.in");
ofstream fout("data.out");
const int INF=1e12;
/*
    ====================DEMONSTRATION======================


    =========================END===========================

 */
int n;
vector<int>v;
int q;
map<int,int>mp;
void ciur()
{
    for(int i=1;i<=MAX;++i)
        mp[i]=1;
    for(int i=3;i<=MAX;i+=2)
    {
        for(int j=i+i;j<=MAX;j+=i)
        {
                mp[j]=max(mp[j],i);
        }
    }
}
signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ciur();
    cin>>n;
    v.resize(n+1);
    for(int i=1;i<=n;++i)
    {
        cin>>v[i];
    }
    vector<int>ans;
    for(int i=1;i<=n;++i)
    {
        if(v[i]%2==0)
        {
            int aux=mp[v[i]];
            int cnt=v[i]/mp[v[i]];
            while(cnt--)
                ans.pb(aux);
        }
        else
            ans.pb(v[i]);
    }

    cin>>q;
    for(int i=1;i<=q;++i)
    {
        int x;
        cin>>x;
        cout<<ans[x-1]<<nl;

    }




    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 146 ms 6696 KB Output is correct
2 Correct 138 ms 6492 KB Output is correct
3 Correct 159 ms 12992 KB Output is correct
4 Correct 162 ms 9372 KB Output is correct
5 Correct 179 ms 14272 KB Output is correct
6 Correct 169 ms 16788 KB Output is correct
7 Correct 184 ms 17084 KB Output is correct
8 Correct 194 ms 25272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 149 ms 6704 KB Output is correct
2 Correct 146 ms 6492 KB Output is correct
3 Runtime error 145 ms 13136 KB Execution killed with signal 8
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 6696 KB Output is correct
2 Correct 138 ms 6492 KB Output is correct
3 Correct 159 ms 12992 KB Output is correct
4 Correct 162 ms 9372 KB Output is correct
5 Correct 179 ms 14272 KB Output is correct
6 Correct 169 ms 16788 KB Output is correct
7 Correct 184 ms 17084 KB Output is correct
8 Correct 194 ms 25272 KB Output is correct
9 Correct 149 ms 6704 KB Output is correct
10 Correct 146 ms 6492 KB Output is correct
11 Runtime error 145 ms 13136 KB Execution killed with signal 8
12 Halted 0 ms 0 KB -