fork download
  1. import java.io.*;
  2. import java.util.*;
  3. import java.text.*;
  4. import java.math.*;
  5. import java.util.regex.*;
  6.  
  7. class Solution {
  8.  
  9. public static void main(String[] args) {
  10.  
  11. Scanner sc=new Scanner(System.in);
  12. int t=sc.nextInt();
  13. while(t>0)
  14. {
  15. int n=sc.nextInt();
  16. int ans=0;
  17. Map<Integer,Integer> map=new HashMap<>();
  18. map.put(5,0);
  19. map.put(2,0);
  20. for(int i=2;i<=n;i++)
  21. {
  22. int k=i;
  23. while(k>=2)
  24. {
  25. if(k%5==0)
  26. {
  27. k=k/5;
  28. map.put(5,map.get(5)+1);
  29. }
  30. if(k%2==0)
  31. {
  32. k=k/2;
  33. map.put(2,map.get(2)+1);
  34. }
  35. if(k%5!=0 && k%2!=0)
  36. {
  37. k=0;
  38. break;
  39. }
  40. }
  41. }
  42. System.out.println(Math.min(map.get(5),map.get(2))+" ");
  43.  
  44. t--;
  45. }
  46. }
  47. }
Success #stdin #stdout 0.14s 38424KB
stdin
3
2
5
20
stdout
0 
1 
4