Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * author: heWhoCooks
- * created: 2024-12-27 22:45:28
- **/
- #include <bits/stdc++.h>
- using namespace std;
- mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
- #define NeedForSpeed \
- ios_base::sync_with_stdio(false); \
- cin.tie(NULL); \
- cout.tie(NULL);
- #define int long long
- #define all(x) (x).begin(), (x).end()
- typedef vector<int> vi;
- typedef vector<bool> vb;
- typedef vector<vi> vvi;
- typedef vector<pair<int, int>> vpi;
- #define f first
- #define s second
- #define pb push_back
- #define pf push_front
- #define yes cout << "YES" << endl
- #define no cout << "NO" << endl
- #define endl "\n"
- #define M_PI 3.14159265358979323846L
- const int mod = 1e9 + 7;
- const int INF = 2e18;
- int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
- const int N = 1e7 + 5;
- vi sumd(N, 0);
- vi mpp(N, 0);
- void sumof_div()
- {
- // just do O(nlogn)
- for (int i = 1; i < N; i++)
- {
- for (int j = i; j < N; j += i)
- {
- sumd[j] += i;
- }
- // limit on c = 1e7
- if (sumd[i] <= (1e7))
- {
- if (mpp[sumd[i]] == 0)
- {
- mpp[sumd[i]] = i;
- }
- }
- }
- }
- void solve()
- {
- int n;
- cin >> n;
- if (mpp[n] == 0)
- {
- cout << -1 << endl;
- }
- else
- {
- cout << mpp[n] << endl;
- }
- return;
- }
- signed main()
- {
- NeedForSpeed;
- int t = 1;
- cin >> t;
- sumof_div();
- while (t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment