304 North Cardinal St.
Dorchester Center, MA 02124

# Yet Another Cute Girl CodeChef Solution

## Yet Another Cute Girl CodeChef Solution in C++17

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

bool isPrime[10000];
void init()
{
// Since range is very small so not used Sieve
for (int i = 2; i < sizeof(isPrime); ++i) {
int j = 2;
for (; j * j <= i; ++j) {
if (i % j == 0) {
break;
}
}
if (j * j > i) isPrime[i] = true;
}
}
main()
{
init();
int testCases, divisors[1000005];
scanf("%d", &testCases);
while(testCases--) {
long long L, R;
scanf("%lld%lld", &L, &R);
for(long long i=L; i<=R; i++) divisors[i-L] = 0;

for(long long i=1; i*i <= R; i++) {
long long square = i*i;

for(long long j=( (L-1) / i + 1) * i; j <= R; j += i) {
if (j < square) continue;

if( square == j )
divisors[j-L] += 1;
else divisors[j-L] += 2;
}
}
int ans = 0;
for(long long i = L; i <= R; i++) if(isPrime[divisors[i-L]]) ans++;
printf("%d\n",ans);
}
}``````

## Yet Another Cute Girl CodeChef Solution in C++14

``````#include <bits/stdc++.h>

#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("Ofast")//Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

using namespace std;

struct PairHash {inline std::size_t operator()(const std::pair<int, int> &v) const { return v.first * 31 + v.second; }};

// speed
#define Code ios_base::sync_with_stdio(false);
#define By ios::sync_with_stdio(0);
#define Sumfi cout.tie(NULL);

// alias
using ll = long long;
using ld = long double;
using ull = unsigned long long;

// constants
const ld PI = 3.14159265358979323846;  /* pi */
const ll INF = 1e18;
const ld EPS = 1e-9;
const ll MAX_N = 101010;
const ll mod = 998244353;

// typedef
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef array<ll,3> all3;
typedef array<ll,5> all5;
typedef vector<all3> vall3;
typedef vector<all5> vall5;
typedef vector<ld> vld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef deque<ll> dqll;
typedef deque<pll> dqpll;
typedef pair<string, string> pss;
typedef vector<pss> vpss;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef unordered_set<ll> usll;
typedef unordered_set<pll, PairHash> uspll;
typedef unordered_map<ll, ll> umll;
typedef unordered_map<pll, ll, PairHash> umpll;

// macros
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,m,n) for(ll i=n;i>=m;i--)
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define INF(a) memset(a,0x3f3f3f3f3f3f3f3fLL,sizeof(a))
#define ASCEND(a) iota(all(a),0)
#define sz(x) ll((x).size())
#define BIT(a,i) (a & (1ll<<i))
#define BITSHIFT(a,i,n) (((a<<i) & ((1ll<<n) - 1)) | (a>>(n-i)))
#define pyes cout<<"Yes\n";
#define pno cout<<"No\n";
#define endl "\n"
#define pneg1 cout<<"-1\n";
#define ppossible cout<<"Possible\n";
#define pimpossible cout<<"Impossible\n";
#define TC(x) cout<<"Case #"<<x<<": ";
#define X first
#define Y second

// utility functions
template <typename T>
void print(T &&t)  { cout << t << "\n"; }
template<typename T>
void printv(vector<T>v){ll n=v.size();rep(i,0,n){cout<<v[i];if(i+1!=n)cout<<' ';}cout<<endl;}
template<typename T>
void printvln(vector<T>v){ll n=v.size();rep(i,0,n)cout<<v[i]<<endl;}
void fileIO(string in = "input.txt", string out = "output.txt") {freopen(in.c_str(),"r",stdin); freopen(out.c_str(),"w",stdout);}
template<typename T>
template<typename T, typename U>
template<typename T, typename U>

struct Combination {
vll fac, inv;
ll n, MOD;

ll modpow(ll n, ll x, ll MOD = mod) { if(!x) return 1; ll res = modpow(n,x>>1,MOD); res = (res * res) % MOD; if(x&1) res = (res * n) % MOD; return res; }

Combination(ll _n, ll MOD = mod): n(_n + 1), MOD(MOD) {
inv = fac = vll(n,1);
rep(i,1,n) fac[i] = fac[i-1] * i % MOD;
inv[n - 1] = modpow(fac[n - 1], MOD - 2, MOD);
rrep(i,1,n - 2) inv[i] = inv[i + 1] * (i + 1) % MOD;
}

ll fact(ll n) {return fac[n];}
ll nCr(ll n, ll r) {
if(n < r or n < 0 or r < 0) return 0;
return fac[n] * inv[r] % MOD * inv[n-r] % MOD;
}
};

struct Matrix {
ll r,c;
vvll matrix;
Matrix(ll r, ll c, ll v = 0): r(r), c(c), matrix(vvll(r,vll(c,v))) {}

Matrix operator*(const Matrix& B) const {
Matrix res(r, B.c);
rep(i,0,r) rep(j,0,B.c) rep(k,0,B.r) {
res.matrix[i][j] = (res.matrix[i][j] + matrix[i][k] * B.matrix[k][j] % mod) % mod;
}
return res;
}

Matrix copy() {
Matrix copy(r,c);
copy.matrix = matrix;
return copy;
}

Matrix pow(ll n) {
assert(r == c);
Matrix res(r,r);
Matrix now = copy();
rep(i,0,r) res.matrix[i][i] = 1;
while(n) {
if(n & 1) res = res * now;
now = now * now;
n /= 2;
}
return res;
}
};

// geometry data structures
template <typename T>
struct Point {
T y,x;
Point(T y, T x) : y(y), x(x) {}
Point(pair<T,T> p) : y(p.first), x(p.second) {}
Point() {}
void input() {cin>>y>>x;}
friend ostream& operator<<(ostream& os, const Point<T>& p) { os<<p.y<<' '<<p.x<<'\n'; return os;}
Point<T> operator+(Point<T>& p) {return Point<T>(y + p.y, x + p.x);}
Point<T> operator-(Point<T>& p) {return Point<T>(y - p.y, x - p.x);}
Point<T> operator*(ll n) {return Point<T>(y*n,x*n); }
Point<T> operator/(ll n) {return Point<T>(y/n,x/n); }
bool operator<(const Point &other) const {if (x == other.x) return y < other.y;return x < other.x;}
Point<T> rotate(Point<T> center, ld angle) {
ld si = sin(angle * PI / 180.), co = cos(angle * PI / 180.);
ld y = this->y - center.y;
ld x = this->x - center.x;

return Point<T>(y * co - x * si + center.y, y * si + x * co + center.x);
}
ld distance(Point<T> other) {
T dy = abs(this->y - other.y);
T dx = abs(this->x - other.x);
return sqrt(dy * dy + dx * dx);
}

T norm() { return x * x + y * y; }
};

template<typename T>
struct Line {
Point<T> A, B;
Line(Point<T> A, Point<T> B) : A(A), B(B) {}
Line() {}

void input() {
A = Point<T>();
B = Point<T>();
A.input();
B.input();
}

T ccw(Point<T> &a, Point<T> &b, Point<T> &c) {
T res = a.x * b.y + b.x * c.y + c.x * a.y;
res -= (a.x * c.y + b.x * a.y + c.x * b.y);
return res;
}

bool isIntersect(Line<T> o) {
T p1p2 = ccw(A,B,o.A) * ccw(A,B,o.B);
T p3p4 = ccw(o.A,o.B,A) * ccw(o.A,o.B,B);
if (p1p2 == 0 && p3p4 == 0) {
pair<T,T> p1(A.y, A.x), p2(B.y,B.x), p3(o.A.y, o.A.x), p4(o.B.y, o.B.x);
if (p1 > p2) swap(p2, p1);
if (p3 > p4) swap(p3, p4);
return p3 <= p2 && p1 <= p4;
}
return p1p2 <= 0 && p3p4 <= 0;
}

pair<bool,Point<ld>> intersection(Line<T> o) {
if(!this->intersection(o)) return {false, {}};
ld det = 1. * (o.B.y-o.A.y)*(B.x-A.x) - 1.*(o.B.x-o.A.x)*(B.y-A.y);
ld t = ((o.B.x-o.A.x)*(A.y-o.A.y) - (o.B.y-o.A.y)*(A.x-o.A.x)) / det;
return {true, {A.y + 1. * t * (B.y - A.y), B.x + 1. * t * (B.x - A.x)}};
}

//@formula for : y = ax + b
//@return {a,b};
pair<ld, ld> formula() {
T y1 = A.y, y2 = B.y;
T x1 = A.x, x2 = B.x;
if(y1 == y2) return {1e9, 0};
if(x1 == x2) return {0, 1e9};
ld a = 1. * (y2 - y1) / (x2 - x1);
ld b = -x1 * a + y1;
return {a, b};
}
};

template<typename T>
struct Circle {
Point<T> center;
Circle() {}

void input() {
center = Point<T>();
center.input();
}

bool circumference(Point<T> p) {
return (center.x - p.x) * (center.x - p.x) + (center.y - p.y) * (center.y - p.y) == radius * radius;
}

bool intersect(Circle<T> c) {
T d = (center.x - c.center.x) * (center.x - c.center.x) + (center.y - c.center.y) * (center.y - c.center.y);
}

bool include(Circle<T> c) {
T d = (center.x - c.center.x) * (center.x - c.center.x) + (center.y - c.center.y) * (center.y - c.center.y);
}
};

ll __gcd(ll x, ll y) { return !y ? x : __gcd(y, x % y); }
all3 __exgcd(ll x, ll y) { if(!y) return {x,1,0}; auto [g,x1,y1] = __exgcd(y, x % y); return {g, y1, x1 - (x/y) * y1}; }
ll __lcm(ll x, ll y) { return x / __gcd(x,y) * y; }
ll modpow(ll n, ll x, ll MOD = mod) { n%=MOD; if(!x) return 1; ll res = modpow(n,x>>1,MOD); res = (res * res) % MOD; if(x&1) res = (res * n) % MOD; return res; }

ll prime[MAX_N];
void init() {
prime[0] = prime[1] = true;
rep(i,2,MAX_N) {
if(prime[i]) continue;
for(ll j = i * i; j < MAX_N; j += i) prime[j] = true;
}
}

ll solve(ll l, ll r) {
vll A(r-l + 1);
for(ll i = 1; i * i <= r; i++) {
ll pow2 = i * i;
for(ll j = ((l - 1) / i + 1) * i; j <= r; j += i) {
if(j < pow2) continue;
if(pow2 == j) A[j-l] += 1;
else A[j-l] += 2;
}
}
ll res = 0;
rep(i,0,sz(A)) if(!prime[A[i]]) res += 1;
return res;
}
int main() {
Code By Sumfi
cout.precision(12);
init();
ll tc = 1;
cin>>tc;
rep(i,1,tc+1) {
ll l,r;
cin>>l>>r;
print(solve(l,r));
}
return 0;
}``````

## Yet Another Cute Girl CodeChef Solution in PYTH 3

``````from bisect import bisect
from math import sqrt,floor
prime = []
isprime = [True]*(10**6 + 2)
isprime[0] = False
isprime[1] = False
for x in range(2,10**6+2):
if(isprime[x]):
prime.append(x)
for i in range(2*x,10**6+2,x):
isprime[i] = False
for _ in range(int(input())):
a,b = map(int,input().split())
sq_rt = floor(sqrt(b)) + 1
index = bisect(prime,sq_rt)
arr = prime[:index]
ans = 0
if(a<=1):
a=2
isprime = [True]*(b-a+1)
for x in arr:
st = floor(a/x)*x
if(st<a):
st+=x
if(st==x):
st+=x
st = st-a
for y in range(st,b-a+1,x):
if(isprime[y]==True):
isprime[y] = [x]
else:
isprime[y].append(x)
for x in range(b-a+1):
if(isprime[x]==True):
ans+=1
else:
temp = 1
val = a+x
if(sqrt(val) == int(sqrt(val))):
c = 0
while(val>1 and c<len(isprime[x])):
elem = isprime[x][c]
t = 0
while(val%elem==0):
t+=1
val = val//elem
temp *= (1+t)
c+=1
pos = bisect(prime,temp) - 1
if(prime[pos]==temp):
ans+=1
else:
continue
print(ans)``````

## Yet Another Cute Girl CodeChef Solution in C

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

void scani(int *z){
*z=0;
char c;
int mul=1;
c=getchar_unlocked();
while(c!='-'&&( c<'0'||c>'9'))
c=getchar_unlocked();
if(c=='-')
mul=-1,c=getchar_unlocked();
while(c>='0'&&c<='9'){
*z=(*z<<3)+(*z<<1)+(c-'0')*mul;
c=getchar_unlocked();
}
}

int main(void) {
int t,n,k,i,j,c,z,p,fact[1000005];
long long int l,r,arr[1000005],q,w;
char a[1000005]={1,1};
for(i=4;i*2<1000000;i+=2)
a[i]=1;
for(i=3;i*i<1000000;i+=2){
if(a[i])
continue;
for(j=i*i;j<1000000;){
a[j]=1;
j+=2*i;
}
}
scani(&t);
while(t--){
k=0;
scanf("%lld%lld",&l,&r);
if(l<2)
l=2;
for(w=l;w<=r;w++){
arr[w-l]=w;
fact[w-l]=1;
}
for(w=2;w*w<=r;w++){
if(a[w])
continue;
for(q=((l-1)/w+1)*w;q<=r;q+=w){
c=0;
p=q-l;
while(arr[p]%w==0){
arr[p]/=w;
c++;
}
fact[p]*=c+1;
}
}
for(i=0;i<=r-l;i++){
if(arr[i]>1){
fact[i]*=2;
}
if(a[fact[i]]==0)
k++;
}
printf("%d\n",k);
}
return 0;
}``````

## Yet Another Cute Girl CodeChef Solution in JAVA

``````//package kg.my_algorithms.codechef;

import jdk.jshell.spi.SPIResolutionException;

import java.io.*;
import java.util.*;
//       NO PROFILE CHECK     AND      Code of Conduct for Future Family
public class Main {
private static final long MOD = 1_000_000_007L;
public static void main(String[] args) throws IOException {
BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
int testCases = fr.nextInt();
HashSet<Integer> primes =new HashSet<>();
int nn = 1_000_001;
boolean[] visited = new boolean[nn+1];
for(int i=2;i<=nn;i++){
if(!visited[i]){
for(int j=i;j<=nn;j+=i) {
visited[j] = true;
}
}
}
for(int testCase=1;testCase<=testCases;testCase++){
long left = fr.nextLong();
long right = fr.nextLong();
int n = (int)(right-left+1);
int[] divisors = new int[n];
int right_limit = (int)Math.sqrt(right);
for(int i=1;i<=right_limit;i++){
long start = ((long)Math.ceil(left/(double)i))*i;
for(long j=start;j<=right;j+=i){
int pos = (int)(j-left);
divisors[pos]++;
long otherSide = j/i;
if(otherSide>right_limit) divisors[pos]++;
}
}
int cnt = 0;
for(int a: divisors) if(primes.contains(a)) cnt++;

//           System.out.println("divisors= " + Arrays.toString(divisors));
sb.append(cnt).append("\n");
}
output.write(sb.toString());
output.flush();
}

}

StringTokenizer st;

{
}

String next() {
while (st == null || !st.hasMoreElements()) {
try {
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt() { return Integer.parseInt(next()); }

long nextLong() { return Long.parseLong(next()); }

double nextDouble()
{
return Double.parseDouble(next());
}

String nextLine()
{
String str = "";
try {
if(st.hasMoreTokens()){
str = st.nextToken("\n");
}
else{
}
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}``````

## Yet Another Cute Girl CodeChef Solution in PYPY 3

``````from bisect import bisect
from math import sqrt,floor

prime = []
isprime = [True]*(10**6 + 2)

isprime[0] = False
isprime[1] = False

for x in range(2,10**6+2):
if(isprime[x]):
prime.append(x)
for i in range(2*x,10**6+2,x):
isprime[i] = False
# print(prime)
for _ in range(int(input())):
a,b = map(int,input().split())
sq_rt = floor(sqrt(b)) + 1
index = bisect(prime,sq_rt)
arr = prime[:index]
ans = 0
if(a<=1):
a=2
isprime = [True]*(b-a+1)
for x in arr:
st = floor(a/x)*x
if(st<a):
st+=x
if(st==x):
st+=x
st = st-a
for y in range(st,b-a+1,x):
if(isprime[y]==True):
isprime[y] = [x]
else:
isprime[y].append(x)
for x in range(b-a+1):
if(isprime[x]==True):
ans+=1
else:
temp = 1
val = a+x
if(sqrt(val) == int(sqrt(val))):
c = 0
while(val>1 and c<len(isprime[x])):
elem = isprime[x][c]
t = 0
while(val%elem==0):
t+=1
val = val//elem
temp *= (1+t)
c+=1
pos = bisect(prime,temp) - 1
#             print(pos,ans,prime[pos])
if(prime[pos]==temp):
ans+=1
else:
continue
#         print(ans)
print(ans)``````

## Yet Another Cute Girl CodeChef Solution in PYTH

``````import bisect

def get_primes1(n=10**6):
sieve =[True] * n
for i in xrange(3, int(n**.5) + 1, 2):
if sieve[i]:
sieve[i*i::2*i] = [False] * ((n - i*i - 1) / (2*i) + 1)
primes = [2] + [i for i in xrange(3, n, 2) if sieve[i]]

primes_power = []
max_ = 10 ** 12
for p in primes:
for e in primes:
if e == 2:
continue
r = p ** (e - 1)
if r > max_:
break
primes_power.append(r)
return primes, sorted(primes_power)

PRIMES, PRIMES_POWER = get_primes1()
#print ">>> ", PRIMES[:10]
#print ">>> ", PRIMES_POWER[:10]

def get_primes2(a, b):
max_ = 10 ** 6
primes_count = 0
i_p = bisect.bisect_left(PRIMES_POWER, a)
j_p = bisect.bisect(PRIMES_POWER, b)
primes_power_count = j_p - i_p

# Case a or/and b are less than 10**6 is already computed.
if a <= max_:
i_p = bisect.bisect_left(PRIMES, a)
a = max_ + 1
if b <= max_:
j_p = bisect.bisect(PRIMES, b)
return j_p - i_p + primes_power_count
else:
primes_count = len(PRIMES) - i_p

# Get primes between a and b.
sieve = [True] * (b - a + 1)
for p in PRIMES:
if a % p == 0:
i = a
else:
i = a + p - (a % p)
sieve[i-a::p] = [False] * ((b - i) / p + 1)
s = a
while s <= b:
primes_count += sieve[s-a]
s += 1
return primes_count + primes_power_count

def main():
t = int(raw_input())
for _ in xrange(t):
a, b = map(int, raw_input().split())
print get_primes2(a, b)

if __name__ == '__main__':
main()``````

## Yet Another Cute Girl CodeChef Solution in C#

``````using System;

static class program
{
public static void Main()
{
bool[] prime = new bool[1000001];
prime[0] = prime[1] = false;
int[] primes = new int[1000000];
int pc = 0;
for (int i = 2; i <= 1000000; ++i)
{
prime[i] = true;
}
for (int i = 2; i <= 1000000; ++i)
{
if (prime[i] == true)
{
primes[pc++] = i;
for (int j = 2; i * j <= 1000000; ++j)
{
prime[i * j] = false;
}
}
}
for (int i = 0; i < t; ++i)
{
long l, r;
l = long.Parse(ip[0]);
r = long.Parse(ip[1]);
if (l == 1) ++l;
long n = r - l + 1;
bool[] segment = new bool[n];
for (int j = 0; j < n; ++j)
{
segment[j] = true;
}

for (int k = 0; k < pc && primes[k]<=Math.Sqrt(r); ++k)
{
long st = (long)Math.Ceiling(1.0 * l / primes[k]);
st *= primes[k];
if (st == 1 || primes[k] == st)
{
st += primes[k];
}
for (; st <= r; st += primes[k])
{
segment[st - l] = false;
}
}

int ans=0;
for (int j = 0; j < n; ++j)
{
if (segment[j] == true) ++ans;
}
//Console.WriteLine(ans);
for (int j = 0; primes[j] <= Math.Sqrt(r) && j<pc; ++j)
{
int sol1 = (int)(Math.Log(r)/Math.Log(primes[j]));
int sol2 = (int)Math.Ceiling(Math.Log(l)/Math.Log(primes[j]));
for (int k = sol2; k <= sol1; ++k)
{
if (k >= 2 && prime[k + 1] == true) ++ans;
}
}
Console.WriteLine(ans);
}
}
}``````

## Yet Another Cute Girl CodeChef Solution in GO

``````package main

import (
"fmt"
//"time"
)

const (
max_prime = 100000
)
var sieve [max_prime]bool
var primes []int

func fill_sieve() {
n := len(sieve)
sieve[0] = true
sieve[1] = true
for i := 2; i * i < n; i++ {
if sieve[i] {
//i is not a prime
continue
}
for j := i * i; j < n; j += i {
sieve[j] = true
}
}
}

func append_primes() {
for i, v := range sieve {
if !v {
primes = append(primes, i)
}
}
}

func prepare_primes() {
fill_sieve()
//append_primes()
}

func main() {
//	defer func(start time.Time) {
//		fmt.Println("Solution Time:", time.Since(start))
//	}(time.Now())

prepare_primes()
var interval [1000*1000 + 1]int
for i := uint64(0); i < 1000*1000 + 1; i++ {
interval[i] = 2
}
var T int
fmt.Scan(&T)
for ; T > 0; T-- {
var a, b uint64
fmt.Scan(&a)
fmt.Scan(&b)
if a == 1 {
interval[0] = 1
}
for i := uint64(2); i * i <= b; i++ {
i2 := i * i
begin := a / i * i
if begin < a {
begin += i
}
if begin < i2 {
begin = i2
}
for j := begin; j <= b; j += i {
interval[j - a] += 2
if j == i2 {
interval[j - a]--
}
}
}
count := 0
for i := uint64(0); i <= b - a; i++ {
if !sieve[interval[i]] {
count++
}
interval[i] = 2
}
fmt.Println(count)
}
}

``````
##### Yet Another Cute Girl CodeChef Solution Review:

In our experience, we suggest you solve this Yet Another Cute Girl 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 Yet Another Cute Girl CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Yet Another Cute Girl 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!