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 k, ar[20000010];
- int ar2[20000010];
- void SieveOfEratosthenes()
- {
- int t, i, j, l, n, x;
- for (i = 1; i <= 20000000; i++) ar[i] = i;
- for (x = 2; x <= 4473;)
- {
- for (i = (x * x); i <= 20000000; i = i + x)
- {
- ar[i] = 0;
- }
- for (i = x + 1; ;i++)
- {
- if (ar[i] != 0) {x = i; break;}
- }
- }
- k = 0;
- for (i = 2; i <= 20000000; i++)
- {
- if (ar[i] != 0) {ar2[k] = ar[i]; k++;}
- }
- }
- int main()
- {
- int i, j, n;
- SieveOfEratosthenes();
- for (; ;)
- {
- scanf("%d", &n);
- printf("%d\n", ar2[n - 1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement