Advertisement
ahmad_zizo

T-prime

Feb 17th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. long long int i,x,n,j;
  8. int flag=1;
  9. long long int arr[100000];
  10. scanf("%I64d",&n);
  11. for(i=0;i<n;i++) scanf(" %I64d",&arr[i]);
  12.  
  13. for(i=0; i<n;i++){
  14. flag = 1;
  15. x = sqrt(arr[i]);
  16. if(arr[i] != x*x || (x > 2 && x%2==0)) printf("NO");
  17. else{
  18. for(j=3; j<=sqrt(x); j=j+2)
  19. if(x%j == 0){
  20. flag = 0;
  21. break;
  22. }
  23. if(x<2) flag = 0;
  24. if(flag)
  25. printf("YES");
  26. else printf("NO");
  27. }
  28. if(i!= n-1) printf("\n");
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement