Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Farmers League CodeChef Solution

Problem – Farmers League 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>>

Farmers League CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    if(n==2 || n==3)
	        cout << "3" << endl;
	    else
	    {
	        int max_points = (n-1)*3;
	        int snd_point;
	        int snd_match = n-2;
	        if(snd_match % 2 == 0)
	        {
	            snd_match = snd_match / 2 ;
	            snd_point = snd_match * 3;
	            cout << max_points - snd_point << endl;;
	        }
	        else
	        {
	            snd_match = (snd_match/2)+1;
	            snd_point = snd_match * 3;
	            cout << max_points - snd_point << endl;;
	        }
	    }
	}
	return 0;
}

Farmers League CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n;
	    cin>>n;
	    cout<<3*(n/2)<<endl;
	}
	return 0;
}

Farmers League CodeChef Solution in PYTH 3

# cook your dish here
for i in range(int(input())):
    n=int(input())
    print((n-1)*3-(n-1)//2*3)

Farmers League CodeChef Solution in C

#include <stdio.h>

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

Farmers League 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[] arr=new int[n];
		for(int i=0;i<n;i++)
		{
		    arr[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++)
		{
		    System.out.println(3*(arr[i]/2));
		}
	}
}

Farmers League CodeChef Solution in PYPY 3

t=int(input())
for i in range(t):
    n=int(input())
    print((n//2)*3)
            

Farmers League CodeChef Solution in PYTH

# cook your code here
num = int(input())
for i in range(num):
    X=int(input())
    Y=(3*(X-1))-(3*((X-1)//2))
    print(Y)
    

Farmers League CodeChef Solution in C#

using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		int T = int.Parse(Console.ReadLine());
		for(int i=0;i<T;i++)
		{
		  int N = int.Parse(Console.ReadLine());
		  int max = (N-1)*3;
		  int secondmax = ((N-1) / 2) * 3;
		  Console.WriteLine(max - secondmax);
		}
		
	}
}

Farmers League CodeChef Solution in NODEJS

process.stdin.resume();
process.stdin.setEncoding('utf-8');

var _input_stdin = "";
process.stdin.on('data', function (data) {
    _input_stdin += data;
});


process.stdin.on('end', function () {
    let inp = _input_stdin.split("\n");
	console.log(processInput(...inp));
});

function processInput(t, ...cases){
    t = Number(t);
    let out = [];
    for (let i = 0; i < t; ++i) {
        out.push(processCase(Number(cases[i])));
    }
    return out.join('\n');
}

function processCase(c) {
    let max = c - 1,
        total = max * c / 2,
        sec = Math.ceil((total - max) / max);
    
    return (max - sec) * 3;
}

Farmers League CodeChef Solution in GO

package main
import (
    "bufio"
    "os"
    "strconv"
    "strings"
    "fmt"
)

func main() {
    reader := bufio.NewReader(os.Stdin)
    input_string_raw,_ := reader.ReadString('\n')
    input_string := strings.TrimSpace(input_string_raw)
    t,_ := strconv.ParseInt(input_string,10,64)
    
    for i:=int64(0);i<t;i++ {
        teams_string_raw,_ := reader.ReadString('\n')
        teams_string := strings.TrimSpace(teams_string_raw)
        teams,_ := strconv.Atoi(teams_string)
        
        top_score := (teams-1)*3
        second_top_lowst := ((teams-1)/2)*3
        fmt.Println(top_score - second_top_lowst)
        
    }
}
Farmers League CodeChef Solution Review:

In our experience, we suggest you solve this Farmers League 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 Farmers League CodeChef Solution.

Find on CodeChef

Conclusion:

I hope this Farmers League 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 *