Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Drunk Alcoholic CodeChef Solution

Problem – Drunk Alcoholic CodeChef Solution

This website is dedicated for CodeChef solution where we will publish right solution of all your favourite CodeChef problems along with detailed explanatory of different competitive programming concepts and languages.
<<Previous CodeChef Problem Next Codechef Problem>>

Drunk Alcoholic CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	  
	  int a;
	  cin>>a;
	  
	  int c=0;
	  for(int i=1; i<=a; i++){
	      if( i%2==1 ) c+=3;
	      else c-=1;
	  }
	  cout<<c<<endl;
	}
	return 0;
}

Drunk Alcoholic CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
        int n;
        cin>>n;
        while (n--){
                int x;
                cin>>x;
                if (x==0){
                        cout<<"0"<<endl;
                }
                if (x%2==0 & x!=0){
                        cout<<x<<endl;
                }
                if (x%2!=0){
                        cout<<x+2<<endl;
                }
        }
        
	return 0;
}

Drunk Alcoholic CodeChef Solution in PYTH 3

T = int(input())
for a in range(1,T+1):
    count = 0
    k = int(input())
    for b in range(1,k+1):
        if(b%2 != 0):
            count+=3
        elif(b%2 == 0):
            count-=1
    print(count)    

Drunk Alcoholic CodeChef Solution in C

#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int k,c=0;
	    scanf("%d",&k);
	    for(int i=1;i<=k;i++)
	    {
	        if(i%2!=0)
	        {
	            c=c+3;
	        }
	        else
	        {
	            c=c-1;
	        }
	    }
	    printf("%d\n",c);
	}
	return 0;
}

Drunk Alcoholic CodeChef Solution in JAVA

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int sum=0;
		int[] arr=new int[n];
		for(int i=0;i<n;i++)
		{
		    arr[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++)
		{
		    for(int j=1;j<=arr[i];j++)
		    {
		        if(j%2!=0)
		        {
		            sum+=3;
		        }
		        else if(j%2==0)
		        {
		            sum-=1;
		        }
		    }
		    System.out.println(sum);
		    sum=0;
		}
	
	}
}

Drunk Alcoholic CodeChef Solution in PYPY 3

n=int(input())
for i in range(n):
    a=int(input())
    # z=(a//2*2)+3
    # print(z)

    z=a//2
    w=a-z
    q=w*3-z
    print(q)

Drunk Alcoholic CodeChef Solution in PYTH

# cook your dish here
t=int(input())

for i in range(t):
    f=0
    k=int(input())
    for i in range(1,k+1):
        if i % 2 != 0:
            f+= 3
        else:
            f-= 1
    print(f)

Drunk Alcoholic CodeChef Solution in C#

using System;

public class Test
{
	public static void Main()
	{
		int T = int.Parse( Console.ReadLine() );
		
		while( ( T -- ) > 0 )
		{
		    int K      = int.Parse( Console.ReadLine() );
		    int result = 0;
		    
		    while ( K > 0 )
		    {
		        result += ( (K --) % 2 == 0 ) ? -1 : 3;
		    }
		    
		    Console.WriteLine( result );
		}
	}
}

Drunk Alcoholic CodeChef Solution in NODEJS

process.stdin.resume();
process.stdin.setEncoding('utf8');

// your code goes here

let input = ''

function checkInput(data) {
    input += data
}

function prepareInput() {
    input = input.split('\n')
}

function main() {
    prepareInput()
    
    let N = input.splice(0, 1)
    
    for(let i=0; i<N; i++) {
        let num = Number(input[i])
        
        let ans = num % 2 === 0 ? num : num + 2
        
        process.stdout.write(ans + '\n')
        
    }
}


process.stdin.on('data', checkInput).on('end', main)

Drunk Alcoholic CodeChef Solution in GO

package main
import "fmt"

func main(){
	// your code goes here
	var T, x int
    fmt.Scanf("%d", &T)
    
    for i := 0; i < T; i ++ {
        fmt.Scanf("%d", &x)
        fmt.Println((x-x/2)*3-(x/2))
    }
}
Drunk Alcoholic CodeChef Solution Review:

In our experience, we suggest you solve this Drunk Alcoholic CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Drunk Alcoholic CodeChef Solution.

Find on CodeChef

Conclusion:

I hope this Drunk Alcoholic CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

Cognitive Class Answer

CodeChef Solution

Microsoft Learn

Leave a Reply

Your email address will not be published. Required fields are marked *