|
| 1 | +#define PROB Training |
1 | 2 | #include <cstdio>
|
| 3 | +#include <cstring> |
| 4 | +#include <vector> |
| 5 | +#include <utility> |
| 6 | +#include <algorithm> |
| 7 | +typedef std::pair<int,int> PII; |
| 8 | + |
| 9 | +#define f(x,y,z) for(int x = (y),__ = (z);x < __;++x) |
| 10 | +#define g(x,y,z) for(int x = (y),__ = (z);x <= __;++x) |
| 11 | +#define gd(x,y,z) for(int x = (y),__ = (z);x >= __;--x) |
| 12 | +#define CLR(X) memset(X,0,sizeof(X)) |
| 13 | +#define SET(ARR,X) memset(ARR,X,sizeof(ARR)) |
| 14 | +#define R(X,Y) f(X,0,Y) |
| 15 | +#define G(x,y) g(X,0,Y) |
| 16 | +#define MAXN 2000033 |
| 17 | + |
| 18 | +#ifdef WIN32 |
| 19 | + #define LLD "%I64d" |
| 20 | + #define LLU "%I64u" |
| 21 | +#else |
| 22 | + #define LLD "%lld" |
| 23 | + #define LLU "%llu" |
| 24 | +#endif |
| 25 | + |
| 26 | +typedef long long LL; |
| 27 | +typedef long double real; |
| 28 | + |
| 29 | +int n; |
| 30 | +LL l,r; |
| 31 | +int pri[MAXN]; |
| 32 | +bool isNot[MAXN]; |
| 33 | +int sz; |
| 34 | +LL ans[MAXN]; |
| 35 | +void init(){ |
| 36 | + sz = 0; |
| 37 | + isNot[1] = isNot[0] = 1; |
| 38 | + g(i,2,2000000){ |
| 39 | + if (!isNot[i])pri[sz++] = i; |
| 40 | + f(j,0,sz){ |
| 41 | + if ((LL)i * pri[j] > 2000000)break; |
| 42 | + isNot[ i * pri[j] ] = 1; |
| 43 | + if (i % pri[j] == 0)break; |
| 44 | + } |
| 45 | + } |
| 46 | + int lb,rb,tee; |
| 47 | + // printf("%d\n",sz); |
| 48 | + // f(i,0,10)printf("%d ",pri[i]);puts(""); |
| 49 | + f(i,0,sz){ |
| 50 | + lb = l / pri[i]; |
| 51 | + rb = r / pri[i]; |
| 52 | + // printf("%d %d %d\n",i,lb,rb); |
| 53 | + g(k,lb,rb){ |
| 54 | + tee = k * pri[i] - l; |
| 55 | + if (tee < 0)continue; |
| 56 | + // DIDNT GET AC BECAUSE OF THE FAULT HERE!!!! |
| 57 | + // tee might < 0 and cause RE!!! |
| 58 | + if (!ans[tee])ans[tee] = pri[i]; |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | +int main(){ |
| 63 | +#ifndef LOCAL |
| 64 | + freopen("factor.in","r",stdin); |
| 65 | + freopen("factor.out","w",stdout); |
| 66 | +#endif |
| 67 | + |
| 68 | + scanf("%lld%lld",&l,&r); |
| 69 | + init(); |
| 70 | + g(i,0,r - l){ |
| 71 | + if (!ans[i])ans[i] = i + l; |
| 72 | + // printf("%lld %lld\n",i + l,ans[i]); |
| 73 | + printf("%lld\n",ans[i]); |
| 74 | + } |
| 75 | + |
| 76 | +#ifdef LOCAL |
| 77 | + fclose(stdin); |
| 78 | + fclose(stdout); |
| 79 | +#endif |
| 80 | + return 0; |
| 81 | +} |
0 commit comments