fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. long long prime[2014]={2,3,5,7},i,j,k,count=4,modprod=1;
  7. bool ch;
  8. for(i=9;count<2015;i+=2)
  9. {
  10. k=count;
  11. while(prime[k-1]>sqrt(i))
  12. k--;
  13. ch=true;
  14. for(j=1;j<k;j++)
  15. {
  16. if(i%prime[j]==0)
  17. ch=false;
  18. }
  19. if(ch==true)
  20. {
  21. prime[count]=i;
  22. count++;
  23. }
  24. }
  25. for(i=0;i<2014;i++)
  26. {
  27. modprod*=prime[i];
  28. modprod%=1000;
  29. }
  30. cout<<modprod;
  31. return 0;
  32. }
Success #stdin #stdout 0.14s 3096KB
stdin
Standard input is empty
stdout
330