Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <cmath>
- using namespace std;
- int arr[10000];
- ifstream fin("arma1.in");
- ofstream fout("arma1.out");
- struct factor
- {
- int prime;
- int exp;
- };
- const int DIMCIUR = 44721;
- const int PLIM = 213;
- const int DIMPR = 4648;
- bool ciur[DIMCIUR + 1];
- int prime[DIMPR];
- factor descfac[20];
- void createsieve()
- {
- ciur[0] = true;
- ciur[1] = true;
- ciur[2] = false;
- int p = 2, ix;
- while (p <= PLIM) {
- ix = p * p;
- while (ix <= DIMCIUR) {
- ciur[ix] = true;
- ix += p;
- }
- p++;
- while (ciur[p]) {
- p++;
- }
- }
- }
- int createprimes()
- {
- int ix = 0;
- for (int i = 2; i <= DIMCIUR; i++)
- {
- if (!ciur[i]) {
- prime[ix++] = i;
- }
- }
- return ix;
- }
- int main()
- {
- createsieve();
- int dimp = createprimes();
- int T = 0, n, i, j, k;
- fin >> T >> n;
- for (i = 0; i < n; i++)
- {
- fin >> arr[i];
- }
- long long sum = 0;
- int exp;
- for (i = 0; i < n; i++)
- {
- k = 0;
- j = 0;
- while (arr[i] > 1)
- {
- exp = 0;
- while (arr[i] > 1 && arr[i] % prime[j] == 0)
- {
- exp++;
- arr[i] /= prime[j];
- }
- if (exp > 0)
- {
- descfac[k].prime = prime[j];
- descfac[k].exp = exp;
- k++;
- }
- j++;
- }
- }
- if (T == 1)
- {
- fout << sum << '\n';
- }
- else
- {
- for (i = 0; i < n; i++)
- {
- fout << arr[i] << '\n';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement