message
stringlengths
2
57.2k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
61
108k
cluster
float64
22
22
__index_level_0__
int64
122
217k
Provide tags and a correct Python 3 solution for this coding contest problem. The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal re...
instruction
0
92,929
22
185,858
Tags: implementation Correct Solution: ``` def readln(inp=None): return tuple(map(int, (inp or input()).split())) x, = readln() ans = 0 d = 1 dig = set(list(str(x))) while d * d <= x: if x % d == 0: for var in set((d, x // d)): ans += len(set(list(str(var))).intersection(dig)) > 0 d += 1 pr...
output
1
92,929
22
185,859
Provide tags and a correct Python 3 solution for this coding contest problem. The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal re...
instruction
0
92,934
22
185,868
Tags: implementation Correct Solution: ``` from functools import reduce def factors(n): return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))) n = int(input()) list_ = map(str, factors(n)) n = str(n) cont=0 for el in list_: flag = False for i i...
output
1
92,934
22
185,869
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least ...
instruction
0
92,938
22
185,876
Yes
output
1
92,938
22
185,877
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least ...
instruction
0
92,941
22
185,882
No
output
1
92,941
22
185,883
Provide tags and a correct Python 3 solution for this coding contest problem. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboar...
instruction
0
92,975
22
185,950
Tags: brute force Correct Solution: ``` x, y, xx = map(int, input().split()) cnt = 0 while max(x, y) < xx: if x < y: x, y = y, x l, r, m = 0, 4 * 10 ** 18, 0 while r > l + 1: m = (l + r) // 2; if x >= m * x + y: l = m else: r = m if r == 4e18: ...
output
1
92,975
22
185,951
Provide tags and a correct Python 3 solution for this coding contest problem. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboar...
instruction
0
92,976
22
185,952
Tags: brute force Correct Solution: ``` x,y,m = map(int,input().split()) x,y = min(x,y),max(x,y) if y >= m: print(0) elif y <= 0: print(-1) else: cnt=0 if x<0: cnt += (-x)//y + 1 x = x + cnt*y while y<m: x,y = y,x+y cnt += 1 print(cnt) ```
output
1
92,976
22
185,953
Provide tags and a correct Python 3 solution for this coding contest problem. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboar...
instruction
0
92,977
22
185,954
Tags: brute force Correct Solution: ``` x, y, m = [int(x) for x in input().split()] x, y = min(x, y), max(x, y) if y >= m: print(0) exit(0) if y <= 0: print(-1) exit(0) c = 0 if x < 0 and y > 0: if m <= 0: c = (m - x) // y else: c = -x // y x += c * y while x < m and y < m: xx = x + y if x...
output
1
92,977
22
185,955
Provide tags and a correct Python 3 solution for this coding contest problem. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboar...
instruction
0
92,978
22
185,956
Tags: brute force Correct Solution: ``` x,y,m = map(int,input().strip().split()) x,y = min(x,y),max(x,y) if y>= m: print(0) elif y<=0: print(-1) elif x>=0: i = 0 while y<m: x,y = min(x+y,y) , max(x+y,y) i += 1 print(i) else: n = (y-x)//y if n*y + x < y: n += 1 if n*y + x >= m: print(n) ...
output
1
92,978
22
185,957
Provide tags and a correct Python 3 solution for this coding contest problem. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboar...
instruction
0
92,979
22
185,958
Tags: brute force Correct Solution: ``` x,y,m=map(int,input().split()) x,y=min(x,y),max(x,y) if y>=m:s=0 elif x+y<=x:s=-1 else: s=(y-x+y-1)//y x+=y*s while max(x,y)<m: if x<y:x+=y else:y+=x s+=1 print(s) ```
output
1
92,979
22
185,959
Provide tags and a correct Python 3 solution for this coding contest problem. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboar...
instruction
0
92,980
22
185,960
Tags: brute force Correct Solution: ``` import math a, b, c = map (int, input().split()) if (max (a, b) >= c): print (0) raise SystemExit if (a <= 0 and b <= 0) : print (-1) raise SystemExit tot = 0 if ((a <= 0 and b > 0) or (b <= 0 and a > 0)) : add = max (a, b) menor = min (a, b) adic...
output
1
92,980
22
185,961
Provide tags and a correct Python 3 solution for this coding contest problem. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboar...
instruction
0
92,981
22
185,962
Tags: brute force Correct Solution: ``` x, y, m = [int(x) for x in input().split()] if (x >= m) or (y >= m): print(0) exit() if (x <= 0) and (y <= 0): print(-1) exit() res = 0 if x < 0: res -= x // y x %= y if y < 0: res -= y // x y %= x #print(x, y, res) while (x < m) and (y < m): i...
output
1
92,981
22
185,963
Provide tags and a correct Python 3 solution for this coding contest problem. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboar...
instruction
0
92,982
22
185,964
Tags: brute force Correct Solution: ``` #_________________ Mukul Mohan Varshney _______________# #Template import sys import os import math import copy from math import gcd from bisect import bisect from io import BytesIO, IOBase from math import sqrt,floor,factorial,gcd,log,ceil from collections import deque,Counter,...
output
1
92,982
22
185,965
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We'll call a set of positive integers a beautiful if the following condition fulfills: for any prime p, if <image>, then <image>. In other words, if one number from the set is divisible by prime...
instruction
0
93,007
22
186,014
No
output
1
93,007
22
186,015
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We'll call a set of positive integers a beautiful if the following condition fulfills: for any prime p, if <image>, then <image>. In other words, if one number from the set is divisible by prime...
instruction
0
93,008
22
186,016
No
output
1
93,008
22
186,017
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We'll call a set of positive integers a beautiful if the following condition fulfills: for any prime p, if <image>, then <image>. In other words, if one number from the set is divisible by prime...
instruction
0
93,009
22
186,018
No
output
1
93,009
22
186,019
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We'll call a set of positive integers a beautiful if the following condition fulfills: for any prime p, if <image>, then <image>. In other words, if one number from the set is divisible by prime...
instruction
0
93,010
22
186,020
No
output
1
93,010
22
186,021
Provide tags and a correct Python 3 solution for this coding contest problem. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere. One...
instruction
0
93,163
22
186,326
Tags: brute force, implementation, math, number theory Correct Solution: ``` def solve(n, m, a): if n == 0: return 0, 1 if n == 1: return a[0], 1 d = (a[1]-a[0]) % m if d < 0: d += m st = set(a) cnt = 0 for v in a: cnt += ((v + d) % m) in st cnt = n-cnt d = (d...
output
1
93,163
22
186,327
Provide tags and a correct Python 3 solution for this coding contest problem. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere. One...
instruction
0
93,164
22
186,328
Tags: brute force, implementation, math, number theory Correct Solution: ``` from collections import defaultdict dic = defaultdict(int) def pow_mod(a,b,c): n = 1 m = a v = b if a == 1: return 1 while v > 0: if v%2 == 1: n *= m%c n %= c m *= m ...
output
1
93,164
22
186,329
Provide tags and a correct Python 3 solution for this coding contest problem. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere. One...
instruction
0
93,165
22
186,330
Tags: brute force, implementation, math, number theory Correct Solution: ``` import sys def modInverse(x, y, mod): res = 1 x = x % mod while(y > 0): if(y&1): res = (res * x) % mod y = y // 2 x = (x * x) % mod return res def isEqual(a, b): for i in range(len...
output
1
93,165
22
186,331
Provide tags and a correct Python 3 solution for this coding contest problem. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere. One...
instruction
0
93,166
22
186,332
Tags: brute force, implementation, math, number theory Correct Solution: ``` def solve(n, m, a): if n == 0: return 0, 1 if n == 1: return a[0], 1 d = (a[1]-a[0]) % m if d < 0: d += m st = set(a) cnt = 0 for v in a: cnt += ((v + d) % m) in st cnt = n-cnt d = (d...
output
1
93,166
22
186,333
Provide tags and a correct Python 3 solution for this coding contest problem. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere. One...
instruction
0
93,167
22
186,334
Tags: brute force, implementation, math, number theory Correct Solution: ``` from functools import reduce def gcd_extended(bigger, less): if less == 0: return(bigger, 1, 0) mod = bigger % less div = bigger // less gcd, c_less, c_mod = gcd_extended(less, mod) #gcd == c_less * less + c_mod * ...
output
1
93,167
22
186,335
Provide tags and a correct Python 3 solution for this coding contest problem. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look for arithmetical progressions everywhere. One...
instruction
0
93,168
22
186,336
Tags: brute force, implementation, math, number theory Correct Solution: ``` import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,he...
output
1
93,168
22
186,337
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look...
instruction
0
93,169
22
186,338
No
output
1
93,169
22
186,339
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look...
instruction
0
93,170
22
186,340
No
output
1
93,170
22
186,341
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look...
instruction
0
93,171
22
186,342
No
output
1
93,171
22
186,343
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime m. Also, Timofey likes to look...
instruction
0
93,172
22
186,344
No
output
1
93,172
22
186,345
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kuro is currently playing an educational game about numbers. The game focuses on the greatest common divisor (GCD), the XOR value, and the sum of two numbers. Kuro loves the game so much that he...
instruction
0
93,232
22
186,464
No
output
1
93,232
22
186,465
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kuro is currently playing an educational game about numbers. The game focuses on the greatest common divisor (GCD), the XOR value, and the sum of two numbers. Kuro loves the game so much that he...
instruction
0
93,233
22
186,466
No
output
1
93,233
22
186,467
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kuro is currently playing an educational game about numbers. The game focuses on the greatest common divisor (GCD), the XOR value, and the sum of two numbers. Kuro loves the game so much that he...
instruction
0
93,234
22
186,468
No
output
1
93,234
22
186,469
Provide a correct Python 3 solution for this coding contest problem. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 ...
instruction
0
93,439
22
186,878
"Correct Solution: ``` def ms_number(n): count = 1 msnumber_list = [6] while msnumber_list[-1] < n: msnumber_list.append(7 * count + 1) msnumber_list.append(7 * count + 6) count += 1 return msnumber_list[:-1] def ms_prime(n, msnumber_list): msprime_list = [] msprime_fl...
output
1
93,439
22
186,879
Provide a correct Python 3 solution for this coding contest problem. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 ...
instruction
0
93,440
22
186,880
"Correct Solution: ``` def modifiedSieve(): L = 300001 msPrimes = [] isMSPrime = [ True for _ in range(L) ] for i in range(6): isMSPrime[i] = False for i in range(6, L): if isMSPrime[i]: if i % 7 == 1 or i % 7 == 6: msPrimes.append(i) for j...
output
1
93,440
22
186,881
Provide a correct Python 3 solution for this coding contest problem. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 ...
instruction
0
93,441
22
186,882
"Correct Solution: ``` a=[0]*6+[1,0,1,0,0,0,0]*42857 p=[] for i in range(6,300000,7): if a[i]: p+=[i] for j in range(i**2,300000,i): a[j]=0 if a[i+2]: p+=[i+2] for j in range((i+2)**2,300000,i+2): a[j]=0 while 1: n=int(input()) if n==1:break b=...
output
1
93,441
22
186,883
Provide a correct Python 3 solution for this coding contest problem. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 ...
instruction
0
93,442
22
186,884
"Correct Solution: ``` def main(): while True: data = int(input()) if data == 1: break i = 1 factlist = [] while True: item = 7 * i - 1 if item > int(data / 6) + 1: break if data % item == 0: quo = int(data / item) ...
output
1
93,442
22
186,885
Provide a correct Python 3 solution for this coding contest problem. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 ...
instruction
0
93,443
22
186,886
"Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.rea...
output
1
93,443
22
186,887
Provide a correct Python 3 solution for this coding contest problem. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 ...
instruction
0
93,444
22
186,888
"Correct Solution: ``` N = 300000 a = [((i % 7 ==1)or(i % 7 ==6)) for i in range(N)] #print(a[11]) a[1]=0 p =[] for i in range(6,N): if a[i]: p+=[i] for j in range(i * i ,N,i): a[j] = 0 while True: n = int(input()) if n == 1: break print(n,end = ":") for x in p:...
output
1
93,444
22
186,889
Provide a correct Python 3 solution for this coding contest problem. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 ...
instruction
0
93,445
22
186,890
"Correct Solution: ``` from math import floor # 約数全列挙(ソート済み) # n = 24 -> [1,2,3,4,6,8,12,24] def divisor(n): left = [1] right = [n] sup = floor(pow(n,1/2)) for p in range(2,sup+1): if n % p == 0: if p == n//p: left.append(p) continue left.a...
output
1
93,445
22
186,891
Provide a correct Python 3 solution for this coding contest problem. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A positive integer whose remainder divided by 7 is either 1 ...
instruction
0
93,446
22
186,892
"Correct Solution: ``` p = [1]*300010 p[0]=p[1]=0 for i in range(2, 300010): if not(i%7==1 or i%7==6): p[i] = 0 for i in range(2, 300010): if p[i]: for j in range(i*2, 300010, i): p[j] = 0 doyososu = [] for i in range(2, 300010): if p[i]: doyososu.append(i) while True: n = int(input()) if...
output
1
93,446
22
186,893
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A po...
instruction
0
93,447
22
186,894
Yes
output
1
93,447
22
186,895
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A po...
instruction
0
93,448
22
186,896
Yes
output
1
93,448
22
186,897
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A po...
instruction
0
93,449
22
186,898
Yes
output
1
93,449
22
186,899
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A po...
instruction
0
93,450
22
186,900
Yes
output
1
93,450
22
186,901
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A po...
instruction
0
93,451
22
186,902
No
output
1
93,451
22
186,903
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A po...
instruction
0
93,452
22
186,904
No
output
1
93,452
22
186,905
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A po...
instruction
0
93,453
22
186,906
No
output
1
93,453
22
186,907
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not. A po...
instruction
0
93,454
22
186,908
No
output
1
93,454
22
186,909
Provide tags and a correct Python 3 solution for this coding contest problem. Little Victor adores the sets theory. Let us remind you that a set is a group of numbers where all numbers are pairwise distinct. Today Victor wants to find a set of integers S that has the following properties: * for all x <image> the fo...
instruction
0
93,885
22
187,770
Tags: brute force, constructive algorithms, math Correct Solution: ``` def solve(L,R,k): #print(*[(bin(x)[2:]).zfill(max([len(bin(y)[2:]) for y in [L,R]])) for x in [L,R]],sep='\n') if k < 5: if k==1: return [L] elif k==2: if R-L+1==2: if L < (L^R): ...
output
1
93,885
22
187,771
Provide tags and a correct Python 3 solution for this coding contest problem. Little Victor adores the sets theory. Let us remind you that a set is a group of numbers where all numbers are pairwise distinct. Today Victor wants to find a set of integers S that has the following properties: * for all x <image> the fo...
instruction
0
93,886
22
187,772
Tags: brute force, constructive algorithms, math Correct Solution: ``` import random l, r, k = map(int, input().split(' ')) if k == 1: print(l) print(1) print(l) quit() if k == 2: if r == l+1: a = l b = l^r if a <= b: print(a) print(1) pri...
output
1
93,886
22
187,773
Provide tags and a correct Python 3 solution for this coding contest problem. You're given Q queries of the form (L, R). For each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0, p > 1 such that x = ap. Input The first line contains the number of queries Q (1 ≤ Q ≤ ...
instruction
0
94,120
22
188,240
Tags: binary search, math, number theory Correct Solution: ``` import math import bisect import sys def flrt(exp,x): l=max(0,math.floor(x**(1/exp))-3) r= math.floor(x**(1/exp))+3 while l<r: mid=(l+r)//2 if mid**exp<=x: l=mid+1 else: r=mid return l-1...
output
1
94,120
22
188,241
Provide tags and a correct Python 3 solution for this coding contest problem. You're given Q queries of the form (L, R). For each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0, p > 1 such that x = ap. Input The first line contains the number of queries Q (1 ≤ Q ≤ ...
instruction
0
94,121
22
188,242
Tags: binary search, math, number theory Correct Solution: ``` import sys readline = sys.stdin.buffer.readline J = set() for i in range(2000): J.add(i**2) J.add(i**3) Ri = set() for p in range(5, 61, 2): if p%3 == 0: continue for base in range(2, 10**9): if base in J: ...
output
1
94,121
22
188,243
Provide tags and a correct Python 3 solution for this coding contest problem. You're given Q queries of the form (L, R). For each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0, p > 1 such that x = ap. Input The first line contains the number of queries Q (1 ≤ Q ≤ ...
instruction
0
94,122
22
188,244
Tags: binary search, math, number theory Correct Solution: ``` import math import bisect import sys def flrt(exp,x): l=max(0,math.floor(x**(1/exp))-3) r= math.floor(x**(1/exp))+3 while l<r: mid=(l+r)//2 if mid**exp<=x: l=mid+1 else: r=mid return l-1...
output
1
94,122
22
188,245