Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <math.h>
- #include <string.h>
- #define EPS 1e-8
- #define pi 3.1415926535897932384626433832795028841971693993751
- #define N 2147483647
- int GreatestCommonDivisor(int a, int b)
- {
- if (b == 0) return a;
- else GreatestCommonDivisor(b, (a % b));
- }
- int main()
- {
- int i, t, n, m, r, x, z, a, b, c, d, count, flag, y, l, j, k, count2;
- double p, q, u, v, xx, yy, zz;
- int ar[50000];
- ar[0] = 2, ar[1] = 3, ar[2] = 5, ar[3] = 7, ar[4] = 11;
- for (j = 5; j < 4800; j++)
- {
- l = j - 1;
- for (k = ar[j - 1] + 2; ; k = k + 2)
- {
- if ( (k % 5 != 0) && (k % 3 != 0) && (k % 7 != 0) )
- {
- y = k / 2;
- for (a = 4; a < l; a++)
- {
- if (ar[a] > y)
- {
- a = l;
- break;
- }
- if (k % ar[a] == 0)
- {
- break;
- }
- else if (a > 215)
- {
- a = l;
- break;
- }
- }
- if (a == l)
- {
- ar[j] = k;
- break;
- }
- }
- }
- }
- for (; ;)
- {
- if (scanf("%d", &n) == EOF ) break;
- y = n, xx = n, x = n;
- count = 0, flag = 0;
- for (j = 0; j < 4800;)
- {
- if (ar[j] > x) break;
- if (x % ar[j] == 0)
- {
- if (flag == 0)
- {
- yy = 1.0 / ar[j];
- zz = 1.0 - yy;
- xx = xx * zz;
- flag = 1;
- count++;
- }
- x = x / ar[j];
- }
- else
- {
- flag = 0;
- j++;
- }
- }
- if (x != 1)
- {
- yy = 1.0 / x;
- zz = 1.0 - yy;
- xx = xx * zz;
- }
- xx = xx + count;
- printf("%0.0lf\n", xx);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement