Я пытался разделить на два числа типа long long (c ++) во время a for l oop. При этом программа зависает (TLE). Что я могу сделать? ввод, который вызывает cra sh: 947 987654321987654321
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define rline(x) cin.ignore(), getline(cin,x)
#define endl '\n'
using namespace std;
typedef long long ll;
const int MAXN = 1123456;
const int MAXINT = 2147483098;
const ll MAXLL = 9223372036854775258LL;
const ll mod = 10e8+7;
set <ll> primes;
int main()
{
fast;
unsigned long long x, n, ans = 1;
cin >> x >> n;
ll x1 = x;
for (ll i=2; i<=sqrt(x1); i++){
while (x1%i==0) {primes.insert(i); x1/=i;}
}
if (x1!=1) primes.insert(x1);
set<ll>::iterator it;
//for (it = primes.begin(); it!=primes.end(); it++) cout << *it << endl;
for (it = primes.begin(); it!=primes.end(); it++) {
ll pr = *it;
unsigned long long tot = 0, cur = pr;
int lg = log(n)/log(cur);
//cout << n << " " << cur << " " << lg << endl;
for (int i=0; i<lg; i++){
unsigned long long abc = n/cur;
tot = tot+abc;
cur*=pr;
//cout << tot << " " << cur << " " << abc << endl;
}
for (ll i=0; i<tot; i++) ans = (ans*pr)%mod;
}
cout << ans;
return 0;
}
простых чисел - это набор из ll (длинных) nubmers. Вылетает из-за строчки tot + ab c, без нее работает. в чем проблема?