304 North Cardinal St.
Dorchester Center, MA 02124

# Exam Cheating CodeChef Solution

## Exam Cheating CodeChef Solution in C++14

``````
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define Time cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
#define pb push_back
#define mp make_pair
#define line cout << endl;
#define ff first
#define ss second
#define vi vector<int>
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;
#define printv(v)                      \
for (int i = 0; i < (v.size()); i++) \
{                                    \
cout << v[i] << " ";               \
}                                    \
line;
#define onesbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define sp(x, y) fixed << setprecision(y) << x
#define w(x) \
int x;     \
cin >> x;  \
while (x--)
#define tk(x) \
int x;      \
cin >> x;
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
#define debug(x)     \
cerr << #x << " "; \
_print(x);         \
cerr << endl;
#else
#define debug(x)
#endif
template <class T>
void _print(T t)
{
cerr << t;
}

template <class T, class V>
void _print(pair<T, V> p)
{
cerr << "{";
_print(p.ff);
cerr << ",";
_print(p.ss);
cerr << "}";
}

template <class T>
void _print(vector<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}

template <class T>
void _print(vector<vector<T>> v)
{
cerr << "[\n";
for (int l = 0; l < v.size(); l++)
{
{
for (int k = 0; k < v[l].size(); k++)
cerr << v[l][k] << " ";
}
cerr << "\n";
}
cerr << "]";
}

template <class T, class V>
void _print(map<T, V> v)
{
cerr << "[ ";
for (auto i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}

template <class T>
void _print(set<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}

const long long inf = 1e18;
const int MOD = 1e9 + 7;
const int MAX = 1e6;

int numbit(int x)
{
int ans = 0;
while (x > 0)
{
x = x >> 1;
ans++;
}
return ans;
}

int setbit(int x)
{
int ans = 0;
while (x > 0)
{
if (x & 1)
{
ans++;
}
x = x >> 1;
}
return ans;
}

bool isValid(string s)
{
int len = s.size();
for (int i = 0; i < len / 2; i++)
{
if (s[i] != s[len - 1 - i])
return false;
}
return true;
}

void rotateMatrix(vector<vector<int>> &v, int n)
{
for (int i = 0; i < n / 2; i++)
{
for (int j = i; j < n - i - 1; j++)
{
int ptr = v[i][j];
v[i][j] = v[n - 1 - j][i];
v[n - 1 - j][i] = v[n - 1 - i][n - 1 - j];
v[n - 1 - i][n - 1 - j] = v[j][n - 1 - i];
v[j][n - 1 - i] = ptr;
}
}
}

vector<bool> is_prime(10001, 1);
vector<int> primes;

void seive()
{
is_prime[0] = 0;
is_prime[1] = 0;
for (int i = 2; i < 10001; i++)
{
if (is_prime[i])
{
primes.push_back(i);
for (int j = i + i; j < 10001; j += i)
{
is_prime[j] = 0;
}
}
}
}

ll expo (ll x,ll n){
ll result=1;
while (n) {
if (n & 1)
result = result * x % MOD;
n = n / 2;
x = x * x % MOD;
}
return result;
}

int32_t main() {
ll t; cin >> t;
// seive();
while (t--) {
ll a,b;
ll count =0;
cin>>a>>b;
ll num = abs(a-b);
for(ll i =1;i*i<=num;i++){
if(num%i==0) {
if(num/i==i) count++;
else count+=2;}

}
cout<<count<<endl;

}
return 0;
}

// 1b 4d``````

## Exam Cheating CodeChef Solution in PYTH 3

``````import math
for _ in range(int(input())):
A, B = list(map(int, input().split()))
if A == B:
print(-1)
continue
x = abs(A-B)
factors = set()
for i in range(1, int(math.sqrt(x)) + 1):
print(len(factors))``````

## Exam Cheating CodeChef Solution in C

``````#include <stdio.h>
#include<math.h>
int main(void) {
int t;
scanf("%d",&t);
while(t--)
{
int p=0,a,b;
scanf("%d %d",&a,&b);
int max=abs(a-b);
if(a==b)
printf("-1\n");
else
{
for(int i=1;i<=sqrt(max);i++)
{
if(max%i==0)
{
if(max/i==i)
p+=1;
else
p+=2;
}
}
printf("%d\n",p);
}
}

return 0;
}``````

## Exam Cheating CodeChef Solution in JAVA

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

class ExamCht {
public static void main(String[] args) throws java.lang.Exception {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while (t-- > 0){
int A = s.nextInt();
int B = s.nextInt();
int min;
int x;
if (A < B){
min = A;
x = B-A;
}
else {
min = B;
x = A-B;
}
int p = 0;
for (int j = 1; j <= Math.sqrt(x);j++){
if (x%j == 0 && j != Math.sqrt(x)){
p+=2;
}
else if (x%j == 0 && j == Math.sqrt(x)){
p++;
}
}
System.out.println(p);
}
}
}``````

## Exam Cheating CodeChef Solution in PYPY 3

``````from math import *
for _ in range(int(input())):
A, B = map(int, input().split())
if A == B:
print(-1)
continue
g = abs(A - B)
j, ans = 1, 0
while j * j <= g:
if g % j == 0:
ans += 1 + (g // j != j)
j += 1
print(ans)``````

## Exam Cheating CodeChef Solution in PYTH

``````N = 11000 # value of N required for prime generation
def primesieve(N):
n = N+1
sieve = [True] * (n/2)
for i in xrange(3,int(n**0.5)+1,2):
if sieve[i/2]:
sieve[i*i/2::i] = [False] * ((n-i*i-1)/(2*i)+1)
# endif
# endfor i
return [2] + [2*i+1 for i in xrange(1,n/2) if sieve[i]]
# end fun
primes = primesieve(N)
def Getfactors(n):
F = []
np = len(primes)
p = -1
while (n > 1) and (p < np-1):
p += 1
pn = primes[p]
if n%pn == 0:
ct = 0
while n % pn == 0:
n = n / pn
ct += 1
#endwhile
F.append([pn,ct])
# endif
if (pn > n/pn) and (n > pn):
F.append([n,1])
n = 1
# endif
# endwhile
return F
#endwhile
t = int(raw_input())
for i in range(t):
st = raw_input().split()
A = int(st[0])
B = int(st[1])
if A == B:
r = -1
else:
n = abs(A-B)
r = 1
if n > 1:
F = Getfactors(n)
for f in F:
k = f[1]
r = r*(k+1)
# endfor f
# endif
# endif
print r
# endfor i
``````

## Exam Cheating CodeChef Solution in C#

``````using System.Linq;
using System;

namespace COOK114B
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < T; i++)
{
int  d, res;
d = Math.Abs(data[0]-data[1]);
res = (int)Math.Sqrt(d)==(double)Math.Sqrt(d)? -1 : 0;
for (int j = 1; j < (int)Math.Sqrt(d)+1; j++)
{
if(d%j==0){
res += 2;
}
}
Console.WriteLine(res);
}
}
}
}``````

## Exam Cheating CodeChef Solution in GO

``````package main

import (
"bufio"
"fmt"
"os"
)

func readInt(bytes []byte, from int, val *int) int {
i := from
sign := 1
if bytes[i] == '-' {
sign = -1
i++
}
tmp := 0
for i < len(bytes) && bytes[i] != ' ' {
tmp = tmp*10 + int(bytes[i]-'0')
i++
}
*val = tmp * sign
return i
}

func readNum(scanner *bufio.Scanner) (a int) {
scanner.Scan()
return
}

func readTwoNums(scanner *bufio.Scanner) (a int, b int) {
a, b = res[0], res[1]
return
}

func readNNums(scanner *bufio.Scanner, n int) []int {
res := make([]int, n)
x := 0
scanner.Scan()
for i := 0; i < n; i++ {
for x < len(scanner.Bytes()) && scanner.Bytes()[x] == ' ' {
x++
}
}
return res
}

func fillNNums(scanner *bufio.Scanner, n int, res []int) {
x := 0
scanner.Scan()
for i := 0; i < n; i++ {
for x < len(scanner.Bytes()) && scanner.Bytes()[x] == ' ' {
x++
}
}
}

func readUint64(bytes []byte, from int, val *uint64) int {
i := from

var tmp uint64
for i < len(bytes) && bytes[i] != ' ' {
tmp = tmp*10 + uint64(bytes[i]-'0')
i++
}
*val = tmp

return i
}

func readInt64(bytes []byte, from int, val *int64) int {
i := from
var tmp int64
for i < len(bytes) && bytes[i] != ' ' {
tmp = tmp*10 + int64(bytes[i]-'0')
i++
}
*val = tmp
return i
}

func readNInt64Nums(scanner *bufio.Scanner, n int) []int64 {
res := make([]int64, n)
x := -1
scanner.Scan()
for i := 0; i < n; i++ {
}
return res
}

func main() {
scanner := bufio.NewScanner(os.Stdin)

for tc > 0 {
tc--

fmt.Println(solve(a, b))
}
}

func solve(A, B int) int {
if A == B {
return -1
}

D := abs(A - B)

res := make([]int, 0, 100)

for x := 1; x*x <= D; x++ {
if D%x == 0 {
res = append(res, x)
y := D / x
if x < y {
res = append(res, y)
}
}
}

return len(res)
}

func abs(num int) int {
if num < 0 {
return -num
}
return num
}``````
##### Exam Cheating CodeChef Solution Review:

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

Find on CodeChef

##### Conclusion:

I hope this Exam Cheating 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!