304 North Cardinal St.
Dorchester Center, MA 02124

# Useless Clocks CodeChef Solution

## Useless Clocks CodeChef Solution in C++14

``````#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
ll t;
cin>>t;
while(t--){
ll p,q,n;
cin>>p>>q>>n;
cout<<abs((n-1)*q/((p-q)*2))+1<<endl;
}
return 0;
}``````

## Useless Clocks CodeChef Solution in PYTH 3

``````from sys import stdin,stdout
from math import floor
t=floor((abs(q)*(n-1))/(abs(p-q)*2))+1

## Useless Clocks CodeChef Solution in C

``````#include <stdio.h>

int main(void) {
int T;
scanf("%d", &T);
while (T--) {
long p, q, N;
scanf("%ld %ld %ld", &p, &q, &N);
//float meetRate = 2.0*fabs(q-p)/q;
//long sol = long ( (N-1)*q/(2.0)/fabs(q-p) +1 ) ;
long sol = (N-1)*1.0*q/(2.0*fabs(q-p)) + 1;
printf("%ld\n", sol);
}

return 0;
}``````

## Useless Clocks 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
{

void solve() throws Exception
{
long p,q,n;
p=nl();
q=nl();
n=nl();
n--;
long den=Math.abs(p-q);
long ft=(long)n*q;
ft=ft/den;
ft/=2;
ft++;
System.out.println(ft);

}
void run() throws Exception
{

int t=ni();

while(t-->0)
solve();

}

long nl() throws Exception
{
return Long.parseLong(fr.next());
}

int ni() throws Exception
{
return Integer.parseInt(fr.next());
}

{
StringTokenizer str;

{
}
String next() throws Exception
{
while(str==null || str.hasMoreElements()==false)
{
try
{
}
catch(Exception ee)
{

}
}
return str.nextToken();
}
}

public static void main (String[] args) throws java.lang.Exception
{

try
{
new Codechef().run();

}
catch(Exception ee)
{

}
}
}``````

## Useless Clocks CodeChef Solution in PYTH

``````import math
t  = int(raw_input())

for i in range(t):
p,q,n = map(float,raw_input().split())
n-=1
ans = math.floor(q*n/(2*abs(p-q)))+1
print int(ans)``````

## Useless Clocks CodeChef Solution in GO

``````package main

import "fmt"

func main() {
var t int
fmt.Scanf("%d", &t)

for t > 0 {
var p, q, n int64
fmt.Scanf("%d %d %d", &p, &q, &n)
n--
den := 2 * abs(p-q)
num := q * n

ans := num/den + 1

fmt.Println(ans)

t--
}
}

func abs(a int64) int64 {
if a < 0 {
return -a
}
return a
}``````
##### Useless Clocks CodeChef Solution Review:

In our experience, we suggest you solve thisUseless Clocks 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 Useless Clocks CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Useless Clocks 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!