Advertisement
Ruhan_DIU

Problem C- ACM ICPC Regional Contest

Oct 9th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.Scanner;
  7.  
  8.  
  9. //import java.io.File;
  10.  
  11. import static sun.nio.ch.IOStatus.EOF;
  12.  
  13. public class Main {
  14.  
  15. public static void main(String[] args) throws IOException{
  16. Scanner in=new Scanner(System.in);
  17. InputStreamReader es=new InputStreamReader(System.in);
  18. BufferedReader br=new BufferedReader(es);
  19.  
  20. int test=in.nextInt();
  21. for (int t = 0; t <test ; t++) {
  22. int x=in.nextInt();
  23. int y=in.nextInt();
  24. int target=0;
  25.  
  26. for (int i = x; i <=y ; i++) {
  27. double m=(double)i;
  28. double n=Math.sqrt(m);
  29. int z=(int)n;
  30. int count=0;
  31. for (int j = 1; j <=z ; j++) {
  32. if(i%j==0){
  33. if(j%2==1){
  34. count++;
  35. }
  36. int d=i/j;
  37. if(d!=j){
  38. if(d%2==1){
  39. count++;
  40. }
  41. }
  42. }
  43.  
  44. }
  45.  
  46. if(count%2==1){
  47. target++;
  48. }
  49. }
  50. System.out.println(target);
  51. }
  52.  
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement