Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- class Elephant {
- public static void main(String args[]) {
- Scanner sc=new Scanner(System.in);
- int T=sc.nextInt();
- int G=sc.nextInt();
- int arr[] , N, I , Q ,tail,head;
- try {
- if( 1 <= T && T<= 10 ) {
- if( 1 <= G && G<= 20000 ) {
- for(int i=0;i<G;i++) {
- I=sc.nextInt();
- N=sc.nextInt();
- Q=sc.nextInt();
- tail=head=0;
- if( 1<=N && N<=1000000000 ) {
- arr=new int[N];
- if(( 1<=I && I<=2 ) && ( 1<=Q && Q<=2 )) {
- if(I==1)
- Arrays.fill(arr, 1);
- else
- Arrays.fill(arr, 2);
- for(int z=0;z<N;z++) {
- for(int j=0;j<=z;j++)
- arr[j]+=1;
- }
- for(int z=0;z<N;z++) {
- if(arr[z] % 2 ==0 )
- tail++;
- else
- head++;
- }
- if(Q==1)
- System.out.println(head);
- else
- System.out.println(tail);
- }
- }
- }
- }
- }
- }
- catch(Exception e) {}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement