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.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,498 | 22 | 214,996 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
'''
Hey why peeping here -_'_- ?
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE ,University of Asia Pacific
Todo:
'''
import sys,math
input=sys.stdin.readline
def getSum(k):
return k*(k-1)//2
def HalfDead():
... | output | 1 | 107,498 | 22 | 214,997 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,499 | 22 | 214,998 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
n,k = map(int,input().split())
if 2*n<k*(k+1):
print(-1)
exit(0)
mx = 0
def ok(d):
sm = k*(k-1)//2
sm *= d
if sm+k>n:
return False
if (n-sm>((k-1)*d)):
return True
else:
return False
i = 1
while i*i<=n:
if n%i==0:
if ok(i): mx = max(mx,... | output | 1 | 107,499 | 22 | 214,999 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,500 | 22 | 215,000 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
[n,k]=[int(x) for x in input().split()]
m=k*(k+1)/2
limit=n//m
lul="-1"
def nice(x):
global lul
lul=""
sum=0
a=[0]*k
for i in range(1,k):
a[i-1]=str(i*x)
sum+=i*x
a[k-1]=str(n-sum)
print(" ".join(a))
pep=-1
f... | output | 1 | 107,500 | 22 | 215,001 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,501 | 22 | 215,002 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
import math
import sys
array=list(map(int,input().split()))
n = array[0]
k = array[1]
maxi = -1
for i in range(1, int(math.sqrt(n)) + 1):
if n % i != 0:
continue
del1 = int(i)
del2 = int(n / i)
sum1 = del1 * k * (k - 1) / 2
sum2 = del2 * k * (k... | output | 1 | 107,501 | 22 | 215,003 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,502 | 22 | 215,004 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
import sys
#Library Info(ACL for Python/Pypy) -> https://github.com/not522/ac-library-python
def input():
return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1,0), (0, 1), (-1,0)] #L,D,R,Uの順番
def divisors(n : int):
res = []
for i in ran... | output | 1 | 107,502 | 22 | 215,005 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,503 | 22 | 215,006 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
import sys
#import random
from bisect import bisect_left as lb
from collections import deque
#sys.setrecursionlimit(10**8)
from queue import PriorityQueue as pq
from math import *
input_ = lambda: sys.stdin.readline().strip("\r\n")
ii = lambda : int(inpu... | output | 1 | 107,503 | 22 | 215,007 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,504 | 22 | 215,008 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
import math
n, k = map(int, input().split())
if (k*(k+1))/2 > n:
print(-1)
else:
c = int( n/ ((k*(k+1))/2))
a = []
for i in range(1, int( math.sqrt(n) + 1 ) ):
if i*i == n:
a.append(i)
elif n%i == 0:
... | output | 1 | 107,504 | 22 | 215,009 |
Provide tags and a correct Python 2 solution for this coding contest problem.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,505 | 22 | 215,010 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
def in_num():
return int(raw_input())
def in_arr():
return map(int,raw_in... | output | 1 | 107,505 | 22 | 215,011 |
Provide tags and a correct Python 2 solution for this coding contest problem.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is ... | instruction | 0 | 107,506 | 22 | 215,012 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
def in_num():
return int(raw_input())
def in_arr():
return map(int,raw_in... | output | 1 | 107,506 | 22 | 215,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is ma... | instruction | 0 | 107,507 | 22 | 215,014 |
Yes | output | 1 | 107,507 | 22 | 215,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is ma... | instruction | 0 | 107,508 | 22 | 215,016 |
Yes | output | 1 | 107,508 | 22 | 215,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is ma... | instruction | 0 | 107,509 | 22 | 215,018 |
Yes | output | 1 | 107,509 | 22 | 215,019 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is ma... | instruction | 0 | 107,510 | 22 | 215,020 |
Yes | output | 1 | 107,510 | 22 | 215,021 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is ma... | instruction | 0 | 107,511 | 22 | 215,022 |
No | output | 1 | 107,511 | 22 | 215,023 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is ma... | instruction | 0 | 107,512 | 22 | 215,024 |
No | output | 1 | 107,512 | 22 | 215,025 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is ma... | instruction | 0 | 107,513 | 22 | 215,026 |
No | output | 1 | 107,513 | 22 | 215,027 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a1, a2, ..., ak, that their sum is equal to n and greatest common divisor is ma... | instruction | 0 | 107,514 | 22 | 215,028 |
No | output | 1 | 107,514 | 22 | 215,029 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b ... | instruction | 0 | 107,562 | 22 | 215,124 |
Tags: chinese remainder theorem, math, number theory
Correct Solution:
```
import sys
ints = (int(x) for x in sys.stdin.read().split())
a,b,p,x = (next(ints) for i in range(4))
def ext_gcd(a, b):
"""return (g, x, y) such that a*x + b*y = g = gcd(a, b) and abs(x)<=b+1 ans abs(y)<=a+1"""
x, x1, y, y1 = 0, 1, 1, 0
... | output | 1 | 107,562 | 22 | 215,125 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b ... | instruction | 0 | 107,563 | 22 | 215,126 |
Tags: chinese remainder theorem, math, number theory
Correct Solution:
```
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))
def gcd2(a, b):
... | output | 1 | 107,563 | 22 | 215,127 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b ... | instruction | 0 | 107,564 | 22 | 215,128 |
Tags: chinese remainder theorem, math, number theory
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = 'x' in file.mode... | output | 1 | 107,564 | 22 | 215,129 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b ... | instruction | 0 | 107,565 | 22 | 215,130 |
Tags: chinese remainder theorem, math, number theory
Correct Solution:
```
a,b,p,x=map(int,input().split())
ans=0
for j in range(p-1):
y=b*pow(pow(a,j,p),p-2,p)%p
i=(j-y+p)%p
t=i*(p-1)+j
if(x-t>=0):
ans+=((x-t)//(p*(p-1))+1)
print(ans)
``` | output | 1 | 107,565 | 22 | 215,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b ... | instruction | 0 | 107,566 | 22 | 215,132 |
Tags: chinese remainder theorem, math, number theory
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = 'x' in file.mode... | output | 1 | 107,566 | 22 | 215,133 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b ... | instruction | 0 | 107,567 | 22 | 215,134 |
Tags: chinese remainder theorem, math, number theory
Correct Solution:
```
a,b,p,x = [int(x) for x in input().split()]
ainv = pow(a,p-2,p)
count = 0
n = 1
exp = ainv*b%p
while n<p:
m = n
if exp>n:
m += (n+p-exp)*(p-1)
else:
m += (n-exp)*(p-1)
if m<=x: count += 1 + (x-m)//(p*(p-1)... | output | 1 | 107,567 | 22 | 215,135 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b ... | instruction | 0 | 107,568 | 22 | 215,136 |
Tags: chinese remainder theorem, math, number theory
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = 'x' in file.mode... | output | 1 | 107,568 | 22 | 215,137 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b ... | instruction | 0 | 107,569 | 22 | 215,138 |
Tags: chinese remainder theorem, math, number theory
Correct Solution:
```
# import sys
# sys.stdin = open('in.txt', 'r')
a, b, p, x = map(int, input().split())
# A = [0, 1, 2, .. p-2, p-1] .. length = p
# B = [1, a, a^2, .. a^(p-2)] .. length = p - 1
# x * inv(x) * b = b
# a^x -> inv(a*x) * b
#... | output | 1 | 107,569 | 22 | 215,139 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains ... | instruction | 0 | 107,570 | 22 | 215,140 |
Yes | output | 1 | 107,570 | 22 | 215,141 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains ... | instruction | 0 | 107,571 | 22 | 215,142 |
Yes | output | 1 | 107,571 | 22 | 215,143 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains ... | instruction | 0 | 107,572 | 22 | 215,144 |
Yes | output | 1 | 107,572 | 22 | 215,145 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains ... | instruction | 0 | 107,573 | 22 | 215,146 |
Yes | output | 1 | 107,573 | 22 | 215,147 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains ... | instruction | 0 | 107,574 | 22 | 215,148 |
No | output | 1 | 107,574 | 22 | 215,149 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains ... | instruction | 0 | 107,575 | 22 | 215,150 |
No | output | 1 | 107,575 | 22 | 215,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains ... | instruction | 0 | 107,576 | 22 | 215,152 |
No | output | 1 | 107,576 | 22 | 215,153 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains ... | instruction | 0 | 107,577 | 22 | 215,154 |
No | output | 1 | 107,577 | 22 | 215,155 |
Provide a correct Python 3 solution for this coding contest problem.
We have an integer sequence of length N: A_0,A_1,\cdots,A_{N-1}.
Find the following sum (\mathrm{lcm}(a, b) denotes the least common multiple of a and b):
* \sum_{i=0}^{N-2} \sum_{j=i+1}^{N-1} \mathrm{lcm}(A_i,A_j)
Since the answer may be enormo... | instruction | 0 | 107,660 | 22 | 215,320 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = is_prime[1] = False
for... | output | 1 | 107,660 | 22 | 215,321 |
Provide a correct Python 3 solution for this coding contest problem.
A positive integer may be expressed as a sum of different prime numbers (primes), in one way or another. Given two positive integers n and k, you should count the number of ways to express n as a sum of k different primes. Here, two ways are consider... | instruction | 0 | 107,813 | 22 | 215,626 |
"Correct Solution:
```
primes = []
flag = [0 for i in range(1121)]
for i in range(2, 1121):
if flag[i] == 0:
primes.append(i)
count = 2
while i * count < 1121:
flag[i * count] = 1
count += 1
dp = [[0 for i in range(15)] for j in range(1121)]
dp[0][0] = 1
for p in primes:
for k... | output | 1 | 107,813 | 22 | 215,627 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A positive integer may be expressed as a sum of different prime numbers (primes), in one way or another. Given two positive integers n and k, you should count the number of ways to express n as ... | instruction | 0 | 107,814 | 22 | 215,628 |
No | output | 1 | 107,814 | 22 | 215,629 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* Al... | instruction | 0 | 108,459 | 22 | 216,918 |
"Correct Solution:
```
def gcd(a, b):
while b:
a, b = b, a % b
return a
def prime_decomposition(n):
i = 2
d = {}
while i * i <= n:
while n % i == 0:
n //= i
if i not in d:
d[i] = 0
d[i] += 1
i += 1
if n > 1:
if n not in d:
d[n] = 1
return d
def eratosthene... | output | 1 | 108,459 | 22 | 216,919 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* Al... | instruction | 0 | 108,460 | 22 | 216,920 |
"Correct Solution:
```
def gcd(a, b):
a, b = max(a, b), min(a, b)
while a % b > 0:
a, b = b, a%b
return b
def divisor(a):
i = 1
divset = set()
while i * i <= a:
if a % i == 0: divset |= {i, a//i}
i += 1
divset.remove(1)
return divset
def is_prime(a):
if a <=... | output | 1 | 108,460 | 22 | 216,921 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* Al... | instruction | 0 | 108,461 | 22 | 216,922 |
"Correct Solution:
```
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
... | output | 1 | 108,461 | 22 | 216,923 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* Al... | instruction | 0 | 108,462 | 22 | 216,924 |
"Correct Solution:
```
def prime_fact(n: int)->list:
'''n の素因数を返す
'''
if n < 2:
return []
d = 2
res = []
while n > 1 and d * d <= n:
if n % d == 0:
res.append(d)
while n % d == 0:
n //= d
d += 1
if n > 1:
# n が素数
res.a... | output | 1 | 108,462 | 22 | 216,925 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* Al... | instruction | 0 | 108,463 | 22 | 216,926 |
"Correct Solution:
```
import sys
from fractions import gcd
n = int(input())
a = [int(input()) for _ in range(n+1)]
x = 0
while True:
m = abs(sum([a[i]*pow(x, n-i) for i in range(n+1)]))
if m != 0:
break
x += 1
ps = []
i = 2
while i**2 <= m and i <= n+1:
#for i in range(2, int(sqrt(m))+1):
if m%i == 0:
ps.appe... | output | 1 | 108,463 | 22 | 216,927 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* Al... | instruction | 0 | 108,464 | 22 | 216,928 |
"Correct Solution:
```
from functools import reduce
import random
MOD = 59490679579998635868564022242503445659680322440679327938309703916140405638383434744833220555452130558140772894046169700747186409941317550665821619479140098743288335106272856533978719769677794737287419461899922456614256826709727133515885581878614846... | output | 1 | 108,464 | 22 | 216,929 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* Al... | instruction | 0 | 108,465 | 22 | 216,930 |
"Correct Solution:
```
import sys
from fractions import gcd
n = int(input())
a = [int(input()) for _ in range(n+1)]
x = 0
while True:
m = abs(sum([a[i]*pow(x, n-i) for i in range(n+1)]))
if m != 0:
break
x += 1
ps = []
i = 2
while i**2 <= m and i <= n+1:
if m%i == 0:
ps.append(i)
while m%i == 0:
m //= i
... | output | 1 | 108,465 | 22 | 216,931 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* Al... | instruction | 0 | 108,466 | 22 | 216,932 |
"Correct Solution:
```
def factors(z):
ret = []
for i in range(2, int(z**(1/2))+1):
if z%i == 0:
ret.append(i)
while z%i == 0:
z //= i
if z != 1:
ret.append(z)
return ret
def eratosthenes(N):
if N == 0:
return []
from collections i... | output | 1 | 108,466 | 22 | 216,933 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq... | instruction | 0 | 108,467 | 22 | 216,934 |
Yes | output | 1 | 108,467 | 22 | 216,935 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq... | instruction | 0 | 108,468 | 22 | 216,936 |
Yes | output | 1 | 108,468 | 22 | 216,937 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq... | instruction | 0 | 108,469 | 22 | 216,938 |
Yes | output | 1 | 108,469 | 22 | 216,939 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq... | instruction | 0 | 108,470 | 22 | 216,940 |
Yes | output | 1 | 108,470 | 22 | 216,941 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq... | instruction | 0 | 108,471 | 22 | 216,942 |
No | output | 1 | 108,471 | 22 | 216,943 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq... | instruction | 0 | 108,472 | 22 | 216,944 |
No | output | 1 | 108,472 | 22 | 216,945 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.