Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3. class Elephant {
  4.  
  5. public static void main(String args[]) {
  6.  
  7. Scanner sc=new Scanner(System.in);
  8.  
  9. int T=sc.nextInt();
  10. int G=sc.nextInt();
  11. int arr[] , N, I , Q ,tail,head;
  12.  
  13. try {
  14. if( 1 <= T && T<= 10 ) {
  15.  
  16. if( 1 <= G && G<= 20000 ) {
  17.  
  18. for(int i=0;i<G;i++) {
  19.  
  20. I=sc.nextInt();
  21. N=sc.nextInt();
  22. Q=sc.nextInt();
  23.  
  24. tail=head=0;
  25.  
  26. if( 1<=N && N<=1000000000 ) {
  27.  
  28. arr=new int[N];
  29.  
  30. if(( 1<=I && I<=2 ) && ( 1<=Q && Q<=2 )) {
  31.  
  32. if(I==1)
  33. Arrays.fill(arr, 1);
  34. else
  35. Arrays.fill(arr, 2);
  36.  
  37. for(int z=0;z<N;z++) {
  38.  
  39. for(int j=0;j<=z;j++)
  40. arr[j]+=1;
  41.  
  42. }
  43.  
  44. for(int z=0;z<N;z++) {
  45.  
  46. if(arr[z] % 2 ==0 )
  47. tail++;
  48. else
  49. head++;
  50. }
  51.  
  52. if(Q==1)
  53. System.out.println(head);
  54. else
  55. System.out.println(tail);
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. catch(Exception e) {}
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement