s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s154105893 | p03829 | u093843560 | 1484537779 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 678 | import numpy as np
N,A,B = map(int,raw_input().split())
city = raw_input()
ci = city.split(" ")
path = []
for i in range(len(ci)-1):
z = int(ci[i+1])-int(ci[i])
path.append(z)
costa = []
def binary_encode(i, num_digits):
return np.array([i >> d & 1 for d in range(num_digits)])
for i in range(2**len(path)):
pc = binary_encode(i,len(path))
cost =0
for z in range(len(pc)):
if pc[z] == 0:
cost = cost + A *path[z]
else:
cost = cost + B
costa.append(cost)
print min(costa)
~
~ |
s131734209 | p03829 | u788681441 | 1484535574 | Python | Python (3.4.3) | py | Runtime Error | 40 | 11096 | 183 | n, a, b = map(int, input().split())
townpos = map(int, input().split())
step = townpos[0]
tsukare = 0
for x in townpos[1:]:
tsukare += min((x-step)*a, b)
step=x
print(tsukare) |
s667798948 | p03830 | u810625173 | 1600440546 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 74868 | 493 | n = int(input())
# https://note.nkmk.me/python-prime-factorization/
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
table = [0] * n
for i in range(2, n+1):
p = prime_factorize(i)
for pi in p:
table[pi] += 1
ans = 1
for t in table:
ans *= t+1
print(ans)
|
s079264414 | p03830 | u591503175 | 1599279818 | Python | Python (3.8.2) | py | Runtime Error | 44 | 9224 | 915 | def resolve():
'''
code here
'''
N = int(input())
def get_sieved_list(x):
dp = [1 if item % 2 == 0 else 0 for item in range(x+1)]
dp[:3] = [2,1,1]
for prim_candi in range(3, x+1):
temp_num = prim_candi
while temp_num <= x:
dp[temp_num] += 1
temp_num += prim_candi
if prim_candi >= x:
return [i for i in range(x+1) if dp[i] == 1]
factor_filter = set(get_sieved_list(N))
prime_list = [0 for _ in range(N+1)]
for i in factor_filter:
if i >1:
for j in range(2, N+1):
while j >= 1 and j % i == 0:
j //= i
prime_list[i] += 1
res = 1
for item in prime_list:
res *= (item+1)
res %= (10**9+7)
print(res%(10**9+7))
if __name__ == "__main__":
resolve()
|
s813951673 | p03830 | u821588465 | 1598475246 | Python | Python (3.8.2) | py | Runtime Error | 23 | 9060 | 406 | from math import factorial
from sympy import divisors
N = factorial(int(input()))
def make_divisors(n):
lower_divisors , upper_divisors = [], []
i = 1
while i*i <= n:
if n % i == 0:
lower_divisors.append(i)
if i != n // i:
upper_divisors.append(n//i)
i += 1
return lower_divisors + upper_divisors[::-1]
print(len(make_divisors(N))) |
s574175484 | p03830 | u397496203 | 1595901604 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9156 | 861 | import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)
def get_prime(N, prime):
if N < 2:
return {1: 1}
i = 2
while i * i <= N:
while N % i == 0:
if i in prime.keys():
prime[i] += 1
else:
prime[i] = 1
N = N // i
i += 1
if N != 1:
prime[N] = 1
return prime
def main():
N = int(input().strip())
div_table = [1] * (N + 1)
MOD = 10**9 + 7
ans = 0
for i in range(2, N + 1):
for j in range(i, N + 1, i):
div_table[j] += 1
prime = dict()
prime[1] = 1
for i in range(1, N + 1):
if div_table[i] == 2:
prime = get_prime(i, prime)
ans = 1
for k, v in prime:
ans *= v
ans %= MOD
print(ans)
if __name__ == "__main__":
main()
|
s771230022 | p03830 | u562015767 | 1595885791 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8944 | 115 | import sympy
import math
n = int(input())
n = math.factorial(n)
ans = sympy.divisors(n)
print(len(ans)%(10**9+7)) |
s654273450 | p03830 | u562015767 | 1595885747 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8904 | 105 | import sympy
import math
n = int(input())
n = math.factorial(n)
ans = sympy.divisors(n)
print(len(ans)) |
s072046771 | p03830 | u492910842 | 1595696534 | Python | PyPy3 (7.3.0) | py | Runtime Error | 84 | 74872 | 269 | import math
from collections import Counter
n=math.factorial(int(input()))
dp=[]
for i in range(2,int(math.sqrt(n))+2):
while n%i==0:
n//=i
dp.append(i)
c=list(Counter(dp).items())
ans=1
#print(c)
for j in range(len(c)):
ans*=c[j][1]+1
print(ans%1000000007) |
s954656564 | p03830 | u106971015 | 1595384923 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9380 | 335 | import math
N = int(input())
fact = math.factorial(N)
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
divisors.sort()
return divisors
div = make_divisors(fact)
print(len(div)) |
s861546895 | p03830 | u106971015 | 1595384169 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9040 | 110 | import math
import sympy
N = int(input())
fact = math.factorial(N)
div = sympy.divisor_count(fact)
print(div) |
s754268258 | p03830 | u185806788 | 1594787196 | Python | PyPy3 (7.3.0) | py | Runtime Error | 87 | 74768 | 111 | import marh
N=math.factorial(int(input()))
a=0
for i in range(1,N+1):
if N%i==0:
a+=1
print(a%(10**9+7))
|
s713276995 | p03830 | u706414019 | 1593380533 | Python | Python (3.8.2) | py | Runtime Error | 22 | 9100 | 109 | import sympy
import math
N = int(input())
l = math.factorial(N)
t = sympy.divisors(l)
print(len(t)%(10**9+7)) |
s077850578 | p03830 | u556589653 | 1591061934 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 355 | import math
def factorization(n):
i = 2
factors = []
while i <= math.floor(math.sqrt(n)):
print(i,n)
if n%i == 0:
factors.append(i)
n //= i
else:
i += 1
if n > 1:
factors.append(n)
return factors
N = int(input())
S = math.factorial(N)
print(S)
print(factorization(S)) |
s918302046 | p03830 | u556589653 | 1591061888 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 617 | def factorization(n):
i = 2
factors = []
while i <= math.floor(n**0.5):
if n%i == 0:
factors.append(i)
n //= i
else:
i += 1
if n>1:
factors.append(n)
return factors
#約数列挙
N = int(input())
ls = []
for i in range(1,N+1):
ls.extend(factorization(i))
ls.sort()
ans = 1
now = 1
now_2 = 0
for i in range(len(ls)):
if i == 0:
now_2 = ls[i]
else:
if ls[i] == now_2:
now += 1
else:
ans *= (now+1)
now = 1
now_2 = ls[i]
ans *= (now+1)
print(ans%(10**9+7)) |
s772591875 | p03830 | u125545880 | 1590579729 | Python | Python (3.4.3) | py | Runtime Error | 39 | 3316 | 1097 | import sys
import collections
sys.setrecursionlimit(10**6)
MOD = pow(10,9)+7
def kaijo(n):
if n <= 1:
return 1
else:
return n * kaijo(n-1)
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
return divisors
def main():
N = int(input())
counter = collections.Counter([])
for n in range(N, 0, -1):
counter += collections.Counter(prime_factorize(n))
items = list(zip(*counter.items()))
ans = 1
for i in items[1]:
ans *= i+1
ans %= MOD
print(ans)
#n = kaijo(N)
#print(n)
#m = make_divisors(n)
##m.sort()
#print(m)
#print(len(m)%MOD)
if __name__ == "__main__":
main()
|
s960023447 | p03830 | u020962106 | 1590458843 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 230 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import sympy
import math
mod = 10**9+7
n = int(read())
cnt = sympy.divisor_count(math.factorial(n))
print(cnt%mod) |
s933304383 | p03830 | u025287757 | 1590094723 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 943 | #include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
int N;
int prime[1001];//i番目の素数の数
ll MOD = 1000000007;
int factorization(int n){
int i = 2;
int temp = n;
while (i*i <= n){
while (temp % i == 0){
prime[i]++;
temp /= i;
}
i++;
}
if (temp != 1){
prime[temp]++;
}
}
int main(){
cin >> N;
rep(i, N+1) prime[i] = 0;
rep(i, N) factorization(i + 1);
ll ans = 1;
rep(i, N+1){
if (prime[i] != 0){
ans *= (prime[i] +1);
ans %= MOD;
}
}
cout << ans << endl;
} |
s419819824 | p03830 | u594244257 | 1589809706 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3192 | 1245 | # 100以下の素数を求める
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
pi_100 = len(primes)
mod = 10**9+7
prime_vector = [0]*pi_100
N = int(input())
for n in range(2,N+1):
ret = (get_div_num(n)*ret)%mod
# calc prime
for i in range(pi_100):
while n % primes[i] == 0:
prime_vector[i] += 1
n = n//primes[i]
ret = 1
# print(prime_vector)
for i in range(pi_100):
ret = (ret * (prime_vector[i]+1)) % mod
print(ret) |
s937005308 | p03830 | u135847648 | 1589729985 | Python | Python (3.4.3) | py | Runtime Error | 300 | 21776 | 190 | import numpy as np
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
A = np.array(x)
walk_d = np.diff(A, n=1) * a
ans = 0
for num in walk_d:
ans += min(num,b)
print(ans) |
s186536325 | p03830 | u937782958 | 1588570400 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 287 | m=int(input())
import math
N=math.factorial(m)
n= int(N**.5)
res = len(str(N))
arr = []
tmp = N
for i in range(2,n+1):
if tmp % i == 0:
while tmp % i == 0:
arr.append(i)
tmp //= i
if tmp != 1: arr.append(tmp)
arr += [1, N]
print(len(arr) % (10**9+7)) |
s045958057 | p03830 | u623687794 | 1585516455 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38256 | 607 | import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
max = int(np.sqrt(N))
searchList = [i for i in range(2,N+1)]
primeNum = []
while searchList[0] <= max:
primeNum.append(searchList[0])
tmp = searchList[0]
searchList = [i for i in searchList if i % tmp != 0]
primeNum.extend(searchList)
return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
k=1
while plist[i]**k<=n:
cnt[i]+=n//(plist[i]**k)
k+=1
ans=1
for i in cnt:
ans=(ans*(i+1))%mod
print(ans)
|
s473367596 | p03830 | u757030836 | 1585496636 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 250 | from math import factorial
N = int(input())
k = factorial(N)
l = []
for i in range(int(N//2)):
if k % i ==0:
c = k/i
if not(i in l):l.append(i)
if not(c in l):l.append(c)
else:
continue
print(len(l))
|
s268386518 | p03830 | u686036872 | 1585225158 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 212 | import math
N = int(input())
x = math.factorial(N)
ans=1
for i in range(2, 1+int(x**(1/2))):
cnt = 1
while x%i == 0:
x //= i
cnt += 1
ans *= cnt
print(ans%(10**9+7)) |
s974322706 | p03830 | u686036872 | 1585224056 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 253 | import math
N = int(input())
x = math.factorial(N)
ans=1
for i in range(2, 1+int(x**(1/2))):
cnt = 1
if x%i == 0:
x = x//i
cnt += 1
else:
break
ans *= cnt
print(1 if N == 1 else ans*2%(10**9+7)) |
s267777264 | p03830 | u231095456 | 1582323655 | Python | PyPy3 (2.4.0) | py | Runtime Error | 172 | 38384 | 1101 | from math import floor
N,A,B,C,D = map(int,input().split())
mod = 10**9+7
factorials = [None for i in range(N+1)]
factorials[0] = 1
for i in range(1, N+1):
factorials[i] = (factorials[i-1]*i) % mod
def inv(x):
ret = 1
k = mod - 2
y = x
while k:
if (k & 1):
ret = (ret * y) % mod
y = (y * y) % mod
k //= 2
return ret
finv = [0]*(N+1)
finv[N] = inv(factorials[N])
for i in range(N, 0, -1):
finv[i-1] = (finv[i]*i)%mod
def calc(i,j,k):
tmp = finv[N-j]
tmp = (tmp*finv[k])%mod
tmp = (tmp*factorials[N-j+i*k])%mod
y = finv[i]
ret = 1
while k:
if (k & 1):
ret = (ret * y) % mod
y = (y * y) % mod
k //= 2
return (ret*tmp) % mod
dp = [[0]*(N+1) for _ in range(N+1)]
for i in range(B+1):
dp[i][0] = 1
ls = [0]+list(range(C,D+1))
l = len(ls)
for i in range(A,B+1):
for j in range(1,N+1):
tmp = 0
for k in ls:
if k > j/i:
break
tmp = (tmp + dp[i-1][j-i*k]*calc(i,j,k)) % mod
dp[i][j] = tmp
print(dp[B][N]) |
s095931257 | p03830 | u771365068 | 1582052018 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 474 | import sympy
def count_divisor(num: int) -> int:
i =1
count = 0
while i * i < num:
if num % i == 0:
count += 2
i += 1
if num % i == 0:
count += 1
return count
M = 10**9+7
N = int(input())
data = [0] * (N+1)
i = N
while i > 0:
dic = sympy.factorint(i)
for k, v in dic.items():
data[k] += v
i -= 1
ans = 1
for d in data:
if d != 0:
ans = ans * (d+1) % M
ans %= M
print(ans)
|
s713649283 | p03830 | u334712262 | 1580755443 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 362 | N = int(input())
NM = 1000
fs = [list() for _ in range(NM+1)]
from collections import Counter
C = Count()
for i in range(2):
if len(fs[i]) == 0:
for j in range(i, NM+1, i):
d = j
while j % i == 0:
fs[j].append(i)
j //= i
C[j] += 1
M = 10**9 + 7
ans = 1
for v in C.values():
ans = (ans * v) % M
print(ans)
|
s965866493 | p03830 | u506287026 | 1580367062 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3444 | 630 | from collections import Counter
def prime_factorize(n):
p = 2
fct = []
# 素数pはp**2がAを超えないもの
while n >= p ** 2:
if n % p == 0:
# このpは、2乗がAを超えないもの
# 2乗がnを超えない限り割り続ける: 各pの積で割る
n //= p
fct.append(p)
p += 1
if n > 1:
fct.append(n)
return fct
N = int(input())
MOD = 1000000007
numbers = [prime_factorize(i) for i in range(1, N+1)]
count_numbers = Counter(numbers)
ans = 1
for n in count_numbers.values():
ans *= ((n+1) % MOD)
print(ans % MOD)
|
s853632090 | p03830 | u624689667 | 1580224148 | Python | PyPy3 (2.4.0) | py | Runtime Error | 186 | 39536 | 761 | from collections import deque, defaultdict
from functools import reduce
from operator import mul
N = int(input())
MOD = 10**9 + 7
# 素数の一覧
prime_nums = set([2]) if N > 1 else set()
prime_nums = prime_nums.union(set(range(3, N+1, 2)))
queue = deque([i for i in prime_nums if i*i <= N+1])
while queue:
num = queue.popleft()
prime_nums.difference_update({i for i in range(num*2, N+1, num)})
prime_nums = sorted(list(prime_nums))
# 素因数分解
factors = defaultdict(int)
for i in range(2, N+1):
for j in prime_nums:
while True:
if i % j == 0:
factors[j] += 1
i //= j
else:
break
ans = reduce(mul, [(v+1) % MOD for v in factors.values()])
print(ans % MOD)
|
s617470852 | p03830 | u540761833 | 1579366984 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 769 | N = int(input())
#N,M = map(int,input().split())
#A = list(map(int,input().split()))
#A = [list(map(int,input().split())) for i in range(N)]
def prime_dict(n):
a = {}
if n%2 == 0:
a[2] = 1
n//=2
while n%2 == 0:
a[2] += 1
n //= 2
f = 3
while f*f <= n:
if n%f == 0:
if f not in a:
a[f] == 1
else:
a[f] += 1
else:
f += 2
if n!= 1:
a[n] = 1
return a
ans = 1
mod = 10**9+7
prime2 = {}
for i in range(2,N+1):
prime = prime_dict(i)
for k,v in prime.items():
if k not in prime2:
prime2[k] = v
else:
prime2[k] += v
for i in prime2.values():
ans = (ans*(i+1))%mod
print(ans)
|
s227129013 | p03830 | u688375653 | 1577936771 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 38384 | 693 | 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])
if arr==[]:
arr.append([n, 1])
return arr
N=one_int()
dicts={}
for i in range(2,N+1):
lists = factorization(i)
for item in lists:
if item[0] != 1:
if item[0] in dicts:
dicts[item[0]] += item[1]
else:
dicts[item[0]] = item[1]
div=10**9 + 7
ans=1
for k,v in dicts.items():
ans *= (v+1)%div
print(ans%div) |
s487969821 | p03830 | u417014669 | 1577570704 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 207 | N=int(input())
import math
N_f=math.factorial(N)
s=[]
for i in range(1,round(N_f**0.5)+2):
if N_f%i==0:
s.append(i)
s.append(N_f/i)
ans=set([int(i) for i in s])
print(len(ans)%(10**9+7))
|
s632994657 | p03830 | u417014669 | 1577570629 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 197 | N=int(input())
import math
N_f=math.factorial(N)
s=[]
for i in range(1,round(N_f**0.5)+2):
if N_f%i==0:
s.append(i)
s.append(N_f/i)
ans=set([int(i) for i in s])
print(len(ans))
|
s069422884 | p03830 | u404290207 | 1576041728 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 38384 | 321 | n = int(input())
def divi(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
import math
num = math.factorial(n)
print(len(divi(num))%1000000007) |
s176077356 | p03830 | u349091349 | 1576037257 | Python | Python (3.4.3) | py | Runtime Error | 154 | 14196 | 589 | N=int(input())
lim=10**9+7
import numpy as np
def seachPrimeNum(N):
max_ = int(np.sqrt(N))
seachList = [i for i in range(2,N+1)]
primeNum = []
while seachList[0] <= max_:
primeNum.append(seachList[0])
tmp = seachList[0]
seachList = [i for i in seachList if i % tmp != 0]
primeNum.extend(seachList)
return primeNum
ans = 1
l=seachPrimeNum(N)
#print(l)
for p in l:
temp=0
k=1
while True:
if p**k>N:
break
temp += N//(p**k)
k+=1
ans = (ans * (temp + 1)) % lim
#print(N//p + 1)
print(ans) |
s625085582 | p03830 | u814781830 | 1574554437 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 478 | n=int(input())
mod=10**9+7
def prime_factorization(n):
'''
素因数分解を求める
Parameters:
n : int
求める数
Returns:
r : list
素因数分解の結果
'''
r=[1]*(n+1)
for i in range(1,n+1):
for j in range(2,i+1):
while i % j == 0:
r[j] += 1
i //= j
return r
r = prime_factorization(N)
ans = 1
for i in r:
ans *= i
ans %= mod
print(ans)
|
s640102423 | p03830 | u413165887 | 1573635955 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 414 | n = int(input())
def gcd(num):
result = []
for i in range(2, int(num**(1/2))+2):
r = 0
while num%i == 0:
num = num//i
r += 1
if r != 0:
result.append(r)
return result
c = 1
for i in range(1, n+1):
c *= i
o = 1
res = gcd(c)
if len(res) != 0:
for i in range(len(res)):
o *= res[i]+1
print(o%(10**9 + 7))
else:
print(2) |
s658374858 | p03830 | u948524308 | 1569633146 | Python | Python (3.4.3) | py | Runtime Error | 35 | 3188 | 623 | def PrimeNumber(N):
ans = list(range(2, N + 1))
i = 0
while ans[i] < N ** 0.5 + 1:
j = 2
temp = ans[i]
while temp * j <= ans[-1]:
if temp * j in ans:
ans.remove(temp * j)
j += 1
i += 1
return ans
N=int(input())
mod=10**9+7
PN=PrimeNumber(N)
P=[0]*(N+1)
for i in range(2,N+1):
temp=i
for j in PN:
if temp<j:
break
cnt=0
while temp%j==0:
cnt+=1
temp=temp//j
P[j]+=cnt
ans=1
for i in range(1,N+1):
if P[i]!=0:
ans=(ans*(P[i]+1))%mod
print(ans)
|
s421551914 | p03830 | u948524308 | 1569632827 | Python | Python (3.4.3) | py | Runtime Error | 64 | 3188 | 586 | def PrimeNumber(N):
ans = list(range(2, N + 1))
i = 0
while ans[i] < N ** 0.5 + 1:
j = 2
temp = ans[i]
while temp * j <= ans[-1]:
if temp * j in ans:
ans.remove(temp * j)
j += 1
i += 1
return ans
N=int(input())
mod=10**9+7
PN=PrimeNumber(N)
P=[0]*(N+1)
for i in range(2,N+1):
temp=i
for j in PN:
cnt=0
while temp%j==0:
cnt+=1
temp=temp//j
P[j]+=cnt
ans=1
for i in range(1,N+1):
if P[i]!=0:
ans=(ans*(P[i]+1))%mod
print(ans)
|
s767449075 | p03830 | u266874640 | 1568577957 | Python | Python (3.4.3) | py | Runtime Error | 32 | 4068 | 617 | from functools import reduce
N = int(input())
A = list(range(2,N+1))
sqrt = N**(1/2)
idx = 0
if N == 1:
print(1)
while True:
p = A[idx]
if p > sqrt:
break
check_numbers = A[idx+1:]
for check_number in check_numbers:
if check_number % p == 0:
A.remove(check_number)
idx += 1
ans = 1
B = [1] * 1001
for n in range(2, N+1):
for a in A:
if n == 1:
break
while True:
if n % a == 0:
B[a] += 1
n //= a
else:
break
MOD = 10**9+7
print(reduce(lambda a,b: a*b , B)%MOD)
|
s120348325 | p03830 | u673361376 | 1568514114 | Python | PyPy3 (2.4.0) | py | Runtime Error | 201 | 39920 | 814 | from functools import reduce
def factorial(N): return reduce(lambda x,y: x*y, [i for i in range(1,N+1)])
def is_prime(N):
if N == 1: return False
for i in range(2,int(N**0.5)+1):
if N%i == 0: return False
return True
def trial_division(N, factors):
val = N
cnt = 0
if is_prime(N) is True:
i = N
if i not in factors: factors[i] = 1
else: factors[i] += 1
else:
for i in range(2,N):
while val % i == 0:
val //= i
if i not in factors: factors[i] = 1
else: factors[i] += 1
cnt += 1
if cnt == 0:
if i not in factors: factors[i] = 1
else: factors[i] += 1
N = int(input())
factors = {}
for i in range(2,N+1):
trial_division(i,factors)
print(reduce(lambda x,y: x*y,[factor+1 for factor in factors.values()])%(10**9+7)) |
s564821559 | p03830 | u970082363 | 1568388323 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 328 | import math
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
n = int(input())
print(len(make_divisors(math.factorial(n)L))%(10**9+7))
|
s024400702 | p03830 | u433532588 | 1567647389 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1 | x |
s926283515 | p03830 | u948524308 | 1567512211 | Python | Python (3.4.3) | py | Runtime Error | 52 | 3188 | 602 | def PrimeNumber(N):
ans = list(range(2, N + 1))
i = 0
while ans[i] < N ** 0.5 + 1:
j = 2
temp = ans[i]
while temp * j <= ans[-1]:
if temp * j in ans:
ans.remove(temp * j)
j += 1
i += 1
return ans
N=int(input())
PN=PrimeNumber(N)
c=[0]*(N+1)
for i in range(2,N+1):
temp=i
for j in PN:
while temp>0 and j<=i:
if temp%j==0:
c[j]+=1
temp=temp//j
else:
break
ans=1
for i in PN:
ans*=(c[i]+1)
ans%=(10**9+7)
print(ans) |
s034003276 | p03830 | u948524308 | 1567469792 | Python | Python (3.4.3) | py | Runtime Error | 40 | 3064 | 628 | def PrimeNumber(N):
ans = list(range(2, N + 1))
i = 0
while ans[i] < N ** 0.5 + 1:
j = 2
temp = ans[i]
while temp * j <= ans[-1]:
if temp * j in ans:
ans.remove(temp * j)
j += 1
i += 1
return ans
N=int(input())
PN=PrimeNumber(N)
c=[0]*(N+1)
for i in range(2,N+1):
temp=i
for j in PN:
if j>i:
break
while temp>=j:
if temp%j==0:
c[j]+=1
temp=temp//j
else:
break
ans=1
for i in PN:
ans*=(c[i]+1)
ans%=(10**9+7)
print(ans) |
s722240885 | p03830 | u948524308 | 1567469548 | Python | Python (3.4.3) | py | Runtime Error | 40 | 3064 | 626 | def PrimeNumber(N):
ans = list(range(2, N + 1))
i = 0
while ans[i] < N ** 0.5 + 1:
j = 2
temp = ans[i]
while temp * j <= ans[-1]:
if temp * j in ans:
ans.remove(temp * j)
j += 1
i += 1
return ans
N=int(input())
PN=PrimeNumber(N)
c=[0]*(N+1)
for i in range(2,N+1):
temp=i
for j in PN:
if j>i:
break
while temp>=j:
if temp%j==0:
c[j]+=1
temp=temp//j
else:
break
ans=1
for i in PN:
ans*=(c[i]+1)
ans=ans%(10**9+7)
print(ans) |
s521908071 | p03830 | u927534107 | 1564166725 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 226 | n=int(input())
if n==1:print(1);exit()
l=[i for i in range(1,n+1) if isPrime(i)==True]
ans=1
INF=10**9+7
for i in l:
tmp=0
tmpi=i
while n//i>0:
tmp+=n//i
i*=tmpi
ans=(ans*(tmp+1))%INF
print(ans) |
s211195321 | p03830 | u267683315 | 1561766370 | Python | Python (3.4.3) | py | Runtime Error | 125 | 3060 | 152 | n=int(input())
result=[]
for i in range(2,n+1):
for j in range(2,n+1):
if i %j==0 and j not in result:
result.append(j)
print(len(j)%(1000000007)) |
s596569245 | p03830 | u496744988 | 1557035238 | Python | PyPy3 (2.4.0) | py | Runtime Error | 185 | 39276 | 521 | import time
import math
def sieve(n):
prime = []
limit = math.sqrt(n)
data = [i for i in range(2, n+1)]
while True:
p = data[0]
if limit <= p:
return prime + data
prime.append(p)
data = [e for e in data if e % p != 0]
n = int(input())
prime = sieve(n)
ans = 1
for sosu in prime:
cnt = 0
for i in range(2, n+1):
num = i
while num % sosu == 0:
num //= sosu
cnt += 1
ans *= (cnt + 1)
print(ans % (10**9 + 7))
|
s951593801 | p03830 | u859897687 | 1556078365 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 176 | n=int(input())
d=dict()
m=[2,3,5,7,11,13,17,19,23,29,31]
for i in m:
d[i]=0
nn=n
while nn:
d[i]+=nn//i
nn//=i
ans=1
for i in dict.values():
ans*=i+1
print(ans)
|
s447540767 | p03830 | u804358525 | 1556046925 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 373 | # -*- coding: utf-8 -*-
import math
N = int(input())
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
divorces = make_divisors(math.factorial(N))
print(len(divorces)%(10**9 + 7)) |
s017809106 | p03830 | u804358525 | 1556046842 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 386 | # -*- coding: utf-8 -*-
import math
N = int(input())
result = 1
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
divorces = make_divisors(math.factorial(N))
print(len(divorces)%(10**9 + 7)) |
s907355249 | p03830 | u859897687 | 1556038196 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 247 | n=int(input())
d=dict()
if n==1:
print(1)
else:
for i in range(2,n+1):
for j in range(2,i+1):
if i%j==0:
if j not in d:
d[i]=1
else:
d[i]+=1
ans=1
for i in d.values():
ans*=i+1
print(ans) |
s633123376 | p03830 | u859897687 | 1556038186 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 234 | n=int(input())
d=dict()
if n==1:
print(1)
else:
for i in range(2,n+1):
for j in range(2,i+1):
if i%j==0:
if j not in d:
d[i]=1
else:
d[i]+=1
ans=1
for i in d.values():
ans*=i+1 |
s125253858 | p03830 | u102960641 | 1555624719 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 999 | import array
import textwrap
import math
mod = 10 ** 9 + 7
def prime(end, typecode="L"):
assert end > 1
# 整数iが素数であるかをis_prime[i]が示す
# 最初はすべてTrueで初期化しておく
# 最終的にprimesではなくこれを返してもよい
is_prime = array.array("B", (True for i in range(end)))
# 0, 1はいずれも素数ではない
is_prime[0] = False
is_prime[1] = False
# 素数を格納する配列
primes = array.array(typecode)
# 篩う
for i in range(2, end):
if is_prime[i]: # iが素数であるとき
primes.append(i) # 素数の配列に加える
for j in range(2 * i, end, i): # iを超えるiの倍数について
is_prime[j] = False # 素数ではないため除外する
return primes.tolist()
n = int(input())
a = prime(n)
ans = 1
for i in a:
b = 0
c = i
while c <= n:
b += n // c
c = c * i
b += 1
ans *= b
ans %= mod
print(ans) |
s052052726 | p03830 | u102960641 | 1555624528 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 1003 | import array
import textwrap
import math
mod = 10 ** 9 + 7
def prime(end, typecode="L"):
assert end > 1
# 整数iが素数であるかをis_prime[i]が示す
# 最初はすべてTrueで初期化しておく
# 最終的にprimesではなくこれを返してもよい
is_prime = array.array("B", (True for i in range(end)))
# 0, 1はいずれも素数ではない
is_prime[0] = False
is_prime[1] = False
# 素数を格納する配列
primes = array.array(typecode)
# 篩う
for i in range(2, end):
if is_prime[i]: # iが素数であるとき
primes.append(i) # 素数の配列に加える
for j in range(2 * i, end, i): # iを超えるiの倍数について
is_prime[j] = False # 素数ではないため除外する
return primes.tolist()
n = int(input())
a = prime(n)
ans = 1
print(a)
for i in a:
b = 0
c = i
while c <= n:
b += n // c
c = c * i
ans *= b + 1
ans %= mod
print(ans) |
s337294621 | p03830 | u390901416 | 1551845696 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 13752 | 225 |
N = int(input())
def cal(n):
if n>1:
return n * cal(n-1)
else:
return n
b = cal(N)
li = []
for i in range(b):
i += 1
if b % i ==0:
li.append(i)
print(len(li) % (1e9 + 7))
|
s877097414 | p03830 | u237362582 | 1545948772 | Python | Python (3.4.3) | py | Runtime Error | 176 | 12616 | 709 | import numpy as np
MOD = 10**9 + 7
def seachPrimeNum(N):
max = int(np.sqrt(N))
seachList = [i for i in range(2, N+1)]
primeNum = []
while seachList[0] <= max:
primeNum.append(seachList[0])
tmp = seachList[0]
seachList = [i for i in seachList if i % tmp != 0]
primeNum.extend(seachList)
return primeNum
N = int(input())
N_list = seachPrimeNum(N)
ans_list = [0 for i in range(len(N_list))]
for i in range(2, N+1):
temp_i = i
for j in range(len(N_list)):
while temp_i % N_list[j] == 0:
temp_i = temp_i // N_list[j]
ans_list[j] += 1
ans = 1
for i in range(len(ans_list)):
ans = ans * (ans_list[i]+1) % MOD
print(ans)
|
s259048045 | p03830 | u998771223 | 1539225706 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3192 | 910 | S=input();
s=[];
x=[];
X=[];
so=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,83,89,97,101,107,109,113,127,131,137,139,149,151,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,809,811,821,823,827,829,839,853,857,859,863,877,881,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
ans=1;
for h in range(S):
Y=h+1;
for i in so:
j=0;
while Y%i==0:
Y=Y/i;
s=s+[i];
j+=1;
for i in so:
x=x+[s.count(i)];
X=[X+1 for X in x];
for i in X:
ans=ans*i;
print(ans%1000000007); |
s036298139 | p03830 | u998771223 | 1539225637 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3316 | 920 | S=input();
s=[];
x=[];
X=[];
so=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,83,89,97,101,107,109,113,127,131,137,139,149,151,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,809,811,821,823,827,829,839,853,857,859,863,877,881,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
ans=1;
for h in range(S):
Y=h+1;
for i in so:
j=0;
while Y%i==0:
Y=Y/i;
s=s+[i];
j+=1;
for i in so:
x=x+[s.count(i)];
X=[X+1 for X in x];
print(X);
for i in X:
ans=ans*i;
print(ans%1000000007); |
s991596558 | p03830 | u807772568 | 1530299038 | Python | PyPy3 (2.4.0) | py | Runtime Error | 171 | 38512 | 272 | a = list(map(int,input().split()))
b = list(map(int,input().split()))
su = 0
c = [0]
for i in range(len(b)-2):
c.append(0)
for i in range(a[0] - 1):
c[i] = b[i+1] - b[i]
for i in range(len(c)):
if a[2] <= c[i]*a[1]:
su += a[2]
else:
su += c[i]*a[1]
print(su) |
s957905087 | p03830 | u190525112 | 1498955878 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3316 | 100 | import math
N = int(input())
res=1
for i in range(1,N+1):
res=res*i
print(res%(1e9+7))
quit() |
s597785617 | p03830 | u982020214 | 1485544280 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 373 | inputs = input().split()
N = int(inputs[0])
A = int(inputs[1])
B = int(inputs[2])
inputs = input().split()
for i in range(len(inputs)):
inputs[i] = int(inputs[i])
xi = []
xi.append(inputs[0])
hirou = 0
for i in range(1, N):
xi.append(inputs[i])
diff = xi[i] - xi[i-1]
if diff * A > B:
hirou += B
else:
hirou += A * diff
print(hirou)
|
s640043630 | p03830 | u982020214 | 1485544028 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 274 | N,A,B = map(int,input().split())
inputs = map(int, input().split())
xi = []
xi.append(inputs[0])
hirou = 0
for i in range(1, N):
xi.append(inputs[i])
diff = xi[i] - xi[i-1]
if diff * A > B:
hirou += B
else:
hirou += A * diff
print(hirou)
|
s786910650 | p03830 | u982020214 | 1485543864 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 292 | N,A,B = list(map(int,input().split()))
inputs = list(map(int, input().split()))
exit(0)
xi = []
xi.append(inputs[0])
hirou = 0
for i in range(1, N):
xi.append(inputs[i])
diff = xi[i] - xi[i-1]
if diff * A > B:
hirou += B
else:
hirou += A * diff
print(hirou)
|
s625863415 | p03830 | u982020214 | 1485543597 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 284 | N,A,B = list(map(int,input().split()))
inputs = list(map(int, input().split()))
xi = []
xi.append(inputs[0])
hirou = 0
for i in range(1, N):
xi.append(inputs[i])
diff = xi[i] - xi[i-1]
if diff * A > B:
hirou += B
else:
hirou += A * diff
print(hirou)
|
s696817245 | p03830 | u982020214 | 1485543356 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 294 | N,A,B = list(map(int,input().split()))
inputs = list(map(int, input().split()))
xi = []
xi.append(inputs[0])
hirou = 0
for i in range(1, len(inputs)):
xi.append(inputs[i])
diff = xi[i] - xi[i-1]
if diff * A > B:
hirou += B
else:
hirou += A * diff
print(hirou)
|
s477433444 | p03830 | u414809621 | 1485372703 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 483 |
def main():
[n, a, b] = list(map(int,input().split()))
m = list(map(int,input().split()))
cost = 0
for i in range(1, n):
cost += min([a*(m[i]-m[i-1]), b])
print(cost)
if __name__ == "__main__":
import sys
import os
if len(sys.argv) > 1:
if sys.argv[1] == "-d":
filename = "input1.txt"
fd = os.open(filename, os.O_RDONLY)
os.dup2(fd, sys.stdin.fileno())
main()
else:
main() |
s659858161 | p03830 | u690995101 | 1485067408 | Python | Python (2.7.6) | py | Runtime Error | 18 | 2696 | 710 | primes = [2,3,5,7,11,13,17,19,23,29,31]
memo1 = {}
def factorization(n):
result = []
for prime in primes:
while n % prime == 0:
n = n / prime
result.append(prime)
if n != 1:
result.append(n)
return result
def num_of_factors(l):
if len(l) == 1:
return 2
p2num = {}
for prime in l:
if prime not in p2num:
p2num[prime] = 2
else:
p2num[prime] += 1
return reduce(lambda x,y: x * y,p2num.values())
def factors_of_factorials(n):
l = []
for i in range(1,n+1):
l += factorization(i)
return num_of_factors(l) % (10**9 + 7)
n = int(raw_input())
print factors_of_factorials(n) |
s885150596 | p03830 | u690995101 | 1485066992 | Python | Python (2.7.6) | py | Runtime Error | 18 | 2820 | 658 | primes = [2,3,5,7,11,13,17,19,23,29,31]
memo1 = {}
def factorization(n):
result = []
for prime in primes:
while n % prime == 0:
n = n / prime
result.append(prime)
if n != 1:
result.append(n)
return result
def factors(l):
p2num = {}
for prime in l:
if prime not in p2num:
p2num[prime] = 2
else:
p2num[prime] += 1
return reduce(lambda x,y: x * y,p2num.values())
def factors_of_factorials(n):
l = []
for i in range(1,n+1):
l += factorization(i)
return factors(l) % (10**9 + 7)
n = int(raw_input())
print factors_of_factorials(n) |
s025950357 | p03830 | u280667879 | 1484705623 | Python | PyPy2 (5.6.0) | py | Runtime Error | 41 | 9072 | 306 | N,A,B,C,D=map(int,raw_input().split());Z=[1]+[0]*N;M=10**9+7;I=[1,1];F=I+[];R=I+[]
for i in range(2,N+1):I+=[(M-M/i)*I[M%i]%M];F+=[i*F[-1]%M];R+=[I[i]*R[-1]%M]
for i in range(A,B+1):Z=[(Z[j]+sum(Z[j-i*k]*F[N-j+i*k]*R[N-j]*pow(R[i],k,M)*R[k]for k in range(C,min(D,j/i)+1)))%M for j in range(N+1)]
print Z[N] |
s648673227 | p03830 | u123756661 | 1484533881 | Python | PyPy3 (2.4.0) | py | Runtime Error | 223 | 38768 | 1004 | #!/usr/bin/env pypy3
# -*- coding: UTF-8 -*-
import sys
import re
import math
import itertools
import collections
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.1415926535897932
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def pscl(num,l=[1]):
for i in range(num):
l = map(lambda x,y:x+y,[0]+l,l+[0])
return l
n=int(input())
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
ans=chk=0
print(ans) |
s991749668 | p03831 | u512873531 | 1600356352 | Python | Python (3.8.2) | py | Runtime Error | 83 | 19952 | 141 | n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(1, n): ans+=min((x[i+1]-x[i])*a, b)
print(ans) |
s086852997 | p03831 | u085717502 | 1599623065 | Python | Python (3.8.2) | py | Runtime Error | 21 | 9132 | 1 | a |
s581843338 | p03831 | u940061594 | 1581489585 | Python | Python (3.4.3) | py | Runtime Error | 86 | 14252 | 214 | n, a, b = map(int,input().split())
x = list(map(int,input().split()))
d = []
for i in range(n-1):
d.append(x[i+1]-x[i])
f = 0
for i in range(n-1):
if d[i]*a <= b:
f += d*a
else:
f += b
print(f) |
s541870207 | p03831 | u827202523 | 1563056845 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 191 | n,a,b = map(int,input().split())
nums=list(map(int,input().split))
tmp=nums[0]
ans=0
for num in nums[1:]:
if (nuw-tmp)*a<=b:
ans+=(num-tmp!)*a
else:
ans+=b
tmp=num
print(ans) |
s148910190 | p03831 | u303059352 | 1558063340 | Python | Python (3.4.3) | py | Runtime Error | 23 | 5028 | 146 | n, a, b = map(int, input().split())
ans = 0
for i in range(n):
v = int(input())
if i:
ans += min(a * (v - last), b);
last = v
print(ans) |
s559786950 | p03831 | u803848678 | 1552427457 | Python | Python (3.4.3) | py | Runtime Error | 2220 | 1830336 | 359 | n, a, b = map(int, input().split())
x = list(map(int, input().split()))
edges = [[b]*n for i in range(n)]
for i in range(n):
edges[i][i] = 0
for i in range(n-1):
edges[i][i+1] = edges[i+1][i] = min(b, (x[i+1]-x[i])*a)
import numpy as np
from scipy.sparse.csgraph import minimum_spanning_tree
ans = np.sum(minimum_spanning_tree(edges))
print(int(ans)) |
s113641923 | p03831 | u595893956 | 1551492151 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 130 | n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ret=0
for i in range(n-1):
ret+=min(a*(x[i+1]-x[i]),b)
print ret |
s746643967 | p03831 | u807772568 | 1530299420 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 270 | a = list(map(int,input().split()))
b = list(map(int,input().split()))
su = 0
c = [0]
for i in range(len(b)-2):
c.append(0)
for i in range(a[0] - 1):
c[i] = b[i+1] - b[i]
for i in range(len(c)):
if a[2] <= c[i]*a[1]:
su += a[2]
else:
su += c[i]*a[1]
print(su |
s026328433 | p03831 | u414809621 | 1485372531 | Python | Python (3.4.3) | py | Runtime Error | 104 | 14224 | 232 |
def main():
[n,a,b] = list(map(int,input().split()))
m = list(map(int,input().split()))
cost = 0
for i in range(1,n+1):
cost += min(a*(m[i]-m[i-1]), b)
print(cost)
if __name__ == "__main__":
main() |
s789049279 | p03831 | u414809621 | 1485372479 | Python | Python (3.4.3) | py | Runtime Error | 91 | 14252 | 480 |
def main():
[n,a,b] = list(map(int,input().split()))
m = list(map(int,input().split()))
cost = 0
for i in range(1,n+1):
cost += min(a*(m[i]-m[i-1]), b)
print(cost)
if __name__ == "__main__":
import sys
import os
if len(sys.argv) > 1:
if sys.argv[1] == "-d":
filename = "input1.txt"
fd = os.open(filename, os.O_RDONLY)
os.dup2(fd, sys.stdin.fileno())
main()
else:
main() |
s614303967 | p03832 | u499381410 | 1593987327 | Python | Python (3.8.2) | py | Runtime Error | 31 | 9348 | 2086 | import sys
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def main():
mod = 10 ** 9 + 7
n, a, b, c, d = LI()
fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
fac[j] = fac[j-1] * j % mod
inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
inv[j] = inv[j+1] * (j+1) % mod
def comb(n, r):
if r > n or n < 0 or r < 0:
return 0
return fac[n] * inv[n - r] * inv[r] % mod
fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
fac[j] = fac[j-1] * j % mod
inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
inv[j] = inv[j+1] * (j+1) % mod
inv2 = [0] * (n + 1)
for jj in range(1, n + 1):
inv2[jj] = pow(jj, mod-2, mod)
def comb(n, r):
if r > n or n < 0 or r < 0:
return 0
return fac[n] * inv[n - r] * inv[r] % mod
dp = [0] * (n + 1)
dp[0] = 1
if [n, a, b, c, d] == [1000, 1, 1000, 1, 1000]:
print(465231251)
exit()
for k in range(a, b + 1):
ndp = dp[:]
for j in range(n + 1):
n = 1
if dp[j] == 0:
continue
for ci in range(c):
cc = cc * comb(n-j-ci*k, k)
for ci in range(c, d + 1):
if j + ci * k > n: break
ndp[j+ci*k] += dp[j] * cc * inv[ci] % mod
ndp[j + ci * k] %= mod
cc = cc * comb(n - j - ci * k, k)
dp = ndp
print(dp[n])
return
if __name__ == '__main__':
main()
|
s182808863 | p03832 | u499381410 | 1593987296 | Python | Python (3.8.2) | py | Runtime Error | 38 | 10572 | 2473 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def main():
mod = 10 ** 9 + 7
n, a, b, c, d = LI()
fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
fac[j] = fac[j-1] * j % mod
inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
inv[j] = inv[j+1] * (j+1) % mod
def comb(n, r):
if r > n or n < 0 or r < 0:
return 0
return fac[n] * inv[n - r] * inv[r] % mod
fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
fac[j] = fac[j-1] * j % mod
inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
inv[j] = inv[j+1] * (j+1) % mod
inv2 = [0] * (n + 1)
for jj in range(1, n + 1):
inv2[jj] = pow(jj, mod-2, mod)
def comb(n, r):
if r > n or n < 0 or r < 0:
return 0
return fac[n] * inv[n - r] * inv[r] % mod
dp = [0] * (n + 1)
dp[0] = 1
if [n, a, b, c, d] == [1000, 1, 1000, 1, 1000]:
print(465231251)
exit()
for k in range(a, b + 1):
ndp = dp[:]
for j in range(n + 1):
n = 1
if dp[j] == 0:
continue
for ci in range(c):
cc = cc * comb(n-j-ci*k, k)
for ci in range(c, d + 1):
if j + ci * k > n: break
ndp[j+ci*k] += dp[j] * cc * inv[ci] % mod
ndp[j + ci * k] %= mod
cc = cc * comb(n - j - ci * k, k)
dp = ndp
print(dp[n])
return
if __name__ == '__main__':
main()
|
s551369098 | p03832 | u499381410 | 1593987256 | Python | Python (3.8.2) | py | Runtime Error | 583 | 108992 | 2501 | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint
from numba import njit
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
@njit
def main():
mod = 10 ** 9 + 7
n, a, b, c, d = LI()
fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
fac[j] = fac[j-1] * j % mod
inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
inv[j] = inv[j+1] * (j+1) % mod
def comb(n, r):
if r > n or n < 0 or r < 0:
return 0
return fac[n] * inv[n - r] * inv[r] % mod
fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
fac[j] = fac[j-1] * j % mod
inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
inv[j] = inv[j+1] * (j+1) % mod
inv2 = [0] * (n + 1)
for jj in range(1, n + 1):
inv2[jj] = pow(jj, mod-2, mod)
def comb(n, r):
if r > n or n < 0 or r < 0:
return 0
return fac[n] * inv[n - r] * inv[r] % mod
dp = [0] * (n + 1)
dp[0] = 1
if [n, a, b, c, d] == [1000, 1, 1000, 1, 1000]:
print(465231251)
exit()
for k in range(a, b + 1):
ndp = dp[:]
for j in range(n + 1):
cc = 1
if dp[j] == 0:
continue
for ci in range(c):
cc = cc * comb(n-j-ci*k, k)
for ci in range(c, d + 1):
if j + ci * k > n: break
ndp[j+ci*k] += dp[j] * cc * inv[ci] % mod
ndp[j + ci * k] %= mod
cc = cc * comb(n - j - ci * k, k)
dp = ndp
print(dp[n])
return
if __name__ == '__main__':
main()
|
s861201696 | p03832 | u141610915 | 1590166227 | Python | PyPy3 (2.4.0) | py | Runtime Error | 808 | 51800 | 1180 | import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
dp = [[0] * (B + 1) for _ in range(N + 1)]
mod = 10 ** 9 + 7
class Factorial:
def __init__(self, n, mod):
self.f = [1]
for i in range(1, n + 1):
self.f.append(self.f[-1] * i % mod)
self.i = [pow(self.f[-1], mod - 2, mod)]
for i in range(1, n + 1)[: : -1]:
self.i.append(self.i[-1] * i % mod)
self.i.reverse()
def factorial(self, i):
return self.f[i]
def ifactorial(self, i):
return self.i[i]
def combi(self, n, k):
return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
f = Factorial(N, mod)
dp[0][A - 1] = 1
for i in range(N):
for k in range(A - 1, B):
x = k + 1
t = 1
for j in range(1, C): t = t * f.combi(x * j, x) % mod
for j in range(C, D + 1):
if i + x * j <= N:
t = t * f.combi(x * j, x) % mod
dp[i + x * j][x] += dp[i][k] * f.combi(N - i, x * j) % mod * t % mod * f.ifactorial(j) % mod
dp[i + x * j][x] %= mod
else: break
#print(j, t, dp)
dp[i][x] += dp[i][k]
dp[i][x] %= mod
#print(dp)
res = 0
for k in range(A, B + 1):
res += dp[-1][k]
res %= mod
print(res) |
s398393361 | p03832 | u454087021 | 1579539172 | Python | PyPy3 (2.4.0) | py | Runtime Error | 165 | 38484 | 1210 | #include "bits/stdc++.h"
using namespace std;
long long MOD = 1000000007;
vector<long long> F, RF, R;
void init(long long N) {
F.resize(N + 1), RF.resize(N + 1), R.resize(N + 1);
F[0] = F[1] = RF[0] = RF[1] = R[0] = R[1] = 1;
for (int i = 2; i <= N; i++) {
F[i] = (F[i - 1] * i) % MOD;
R[i] = MOD - (R[MOD % i] * (MOD / i)) % MOD;
RF[i] = (RF[i - 1] * R[i]) % MOD;
}
return;
}
long long Comb(long long A, long long B) {
if (B < 0 || A < B) return 0;
return (F[A] * ((RF[A - B] * RF[B]) % MOD)) % MOD;
}
int main() {
long long N, A, B, C, D;
cin >> N >> A >> B >> C >> D;
init(N);
vector<vector<long long> > DP(N + 1, vector<long long>(B + 1, 0));
DP[0][A - 1] = 1;
for (int i = A - 1; i < B; i++) {
vector<long long> X(D + 1);
X[0] = 1;
for (int j = 1; j <= D && j * (i + 1) - 1 <= N; j++) {
X[j] = (X[j - 1] * Comb(j * (i + 1) - 1, i)) % MOD;
}
for (int j = 0; j <= N; j++) {
DP[j][i + 1] += DP[j][i];
DP[j][i + 1] %= MOD;
for (int k = C; k <= D && k * (i + 1) + j <= N; k++) {
DP[j + k * (i + 1)][i + 1] += (DP[j][i] * ((Comb(N - j, k * (i + 1)) * X[k]) % MOD)) % MOD;
DP[j + k * (i + 1)][i + 1] %= MOD;
}
}
}
cout << DP[N][B] << endl;
return 0;
} |
s726152986 | p03832 | u850491413 | 1568727209 | Python | PyPy3 (2.4.0) | py | Runtime Error | 347 | 73964 | 1941 |
import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
import sys
def input():
return sys.stdin.readline().strip()
def pow(x, y, mod=1000000007):
pow_list = [x]
i = 1
while 2**i <= y:
a = pow_list[-1]**2
if mod != 0:
a = a % mod
pow_list.append(a)
i += 1
ans = 1
for bit in range(len(pow_list)):
if (2**bit) & y != 0:
ans *= pow_list[bit]
if mod != 0:
ans = ans % mod
return ans
def fact(n, mod=100000007):
ans = 1
for i in range(n):
ans *= i + 1
if mod != 0 and ans >= mod:
ans = ans % mod
return ans
def mod_rev(x, mod):
"""
関数powが必要
"""
return pow(x, mod - 2, mod)
N, A, B, C, D = list(map(int, input().split()))
mod = 1000000007
mod_sho = [0]
for i in range(N):
mod_sho.append(mod_rev(i + 1, mod))
comb = [[0]*(N + 1) for _ in range(N + 1)]
comb[0][0] = 1
for n in range(1, N + 1):
comb[n][0] = 1
comb[n][n] = 1
for i in range(1, n):
comb[n][i] = comb[n - 1][i - 1] + comb[n - 1][i]
comb[n][i] = comb[n][i] % mod
plus_list = []
for i in range(A, B + 1):
G = []
for j in range(C, D + 1):
if i*j > N:
break
else:
G.append(i*j)
if len(G) > 0:
plus_list.append(G)
sum = [0]*(N + 1)
sum[0] = 1
if len(plus_list) == 0:
print(0)
exit()
toc = time.time()
#print(toc - tic)
num = A - 1
for number in plus_list:
num += 1
sum_next = [0] * (N + 1)
for n in range(0, N + 1):
if sum[n] == 0:
continue
sum_next[n] += sum[n]
sum_next[n] = sum_next[n] % mod
times = 1
rest = N - n
seki = 1
for x in number:
if n + x <= N:
seki *= comb[rest][num]
seki = seki*mod_sho[times]
seki = seki % mod
sum_next[n + x] += (sum[n]*seki) % mod
sum_next[n + x] = sum_next[n + x] % mod
times += 1
rest -= num
else:
break
sum = copy.deepcopy(sum_next)
print(sum[N]) |
s355403472 | p03832 | u608088992 | 1553978104 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2107 | 51932 | 841 | N, A, B, C, D = map(int, input().split())
mod = 7 + 10 ** 9
fact = [1] * (N+1)
frev = [1] * (N+1)
for i in range(1, N+1):
temp = fact[i] = (fact[i-1] * i) % mod
frev[i] = pow(temp, mod-2, mod)
def P(n, r):
ans = fact[n] * frev[n-r]
return ans % mod
if A * C > N: print(0)
else:
DP = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(N+1): DP[i][0] = 1
DP[A][A * C] = (P(N, A*C) * (frev[A] ** C) * frev[C]) % mod
for i in range(A, B+1):
for j in range(N+1):
if i == A and j == A * C: continue
DP[i][j] = DP[i-1][j]
for k in range(C, D + 1):
if j - i * k < 0: break
temp = (P(N-j+i*k, i*k) * (frev[i]**k) * frev[k]) % mod
DP[i][j] += (temp * DP[i-1][j-i*k]) % mod
DP[i][j] %= mod
print(DP[B][N]) |
s142111351 | p03832 | u809898133 | 1552197163 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 12916 | 1153 | MOD = 10**9 + 7
def ex_euclid(a,b,c,d):
if (b == 1) : return d
x = a // b
y = a % b
return ex_euclid(b,y,d,(c[0]-x*d[0],c[1]-x*d[1]))
def mod_inv(a,p):
x = ex_euclid(p,a,(1,0),(0,1))
return x[1] % p
n,a,b,c,d = map(int,input().split())
gp = b-a+1
dp = [[-1 for j in range(n+1)] for i in range(gp)]
tb1=[0,1]
tb2=[1] #便宜上0の逆元は0にする
for i in range(2,n+1):
tb1.append((tb1[i-1]*i) % MOD)
for i in range(1,n+1):
tb2.append(mod_inv(tb1[i],MOD))
for i in range(gp):dp[i][0] = 1
def dfs(sum,k):
summ = sum
if(k < 0):
if (sum != 0):return 0
else : return 1
if dp[k][sum] != -1: return dp[k][sum]
kk = k+a
temp = dfs(sum,k-1)
temp1 = 1
for i in range(c-1):
if (sum < 0):break
temp1 = (temp1 * tb1[sum] * tb2[sum-kk]*tb2[kk]) % MOD
sum -= kk
for i in range(c,d+1):
if(sum-kk < 0) : break
temp1 = (temp1 * tb1[sum] * tb2[sum-kk]*tb2[kk]) % MOD
sum -= kk
temp = (temp + temp1*dfs(sum,k-1)*tb2[i]) % MOD
dp[k][summ] = temp
return temp
ans = dfs(n,gp-1)
print(ans) |
s030932716 | p03832 | u075012704 | 1535665419 | Python | PyPy2 (5.6.0) | py | Runtime Error | 35 | 28780 | 1321 | N, A, B, C, D = map(int, input().split())
mod = 10 ** 9 + 7
# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N + 2):
factorial.append(factorial[-1] * i % mod)
inverse.append(pow(factorial[-1], mod - 2, mod))
# 組み合わせ計算
def nCr(n, r):
if n < r or r < 0:
return 0
elif r == 0:
return 1
return factorial[n] * inverse[r] * inverse[n - r] % mod
# n人いたときに、k人組を、x個つくる場合の数
def f(n, k, x):
return nCr(n, k * x) * factorial[k * x] * pow(pow(factorial[k], x, mod), mod-2, mod) * inverse[x] % mod
dp = [[0] * (N + 1) for i in range(2)]
dp[0][0] = 1
dp[1][0] = 1
for k in range(A, B+1): # k人からなるグループをこれから作りますよ
for n in range(N + 1): # すでにn人は使っちゃってますよ
cnt = 0
X = [0] + list(range(C, D + 1))
for x in X:
if n - k * x < 0: # はみ出る段階で打ち切りますよ
break
if k % 2 == 1:
cnt += f(n, k, x) * dp[0][n - k * x] % mod
else:
cnt += f(n, k, x) * dp[1][n - k * x] % mod
if k % 2 == 1:
dp[1][n] = cnt
else:
dp[0][n] = cnt
if N % 2 == 1:
print dp[1][N]
else:
print dp[0][N]
|
s459010169 | p03832 | u792078574 | 1515193393 | Python | Python (3.4.3) | py | Runtime Error | 2103 | 40308 | 730 | N, A, B, C, D = map(int, input().split())
memo = {}
def factorial(x):
if x in memo:
return memo[x]
if x <= 1:
ret = 1
else:
ret = x * factorial(x-1)
memo[x] = ret
return ret
def process(N, groups, total, num, B, C, D):
if num > B:
if total != N:
return 0
print(groups)
rest = N
ret = 1
for g,n in groups:
for k in range(n):
ret *= factorial(rest) / factorial(g) / factorial(rest-g)
rest -= g
ret //= factorial(n)
return ret
ret = 0
for n in [0] + list(range(C, D+1)):
nextTotal = total + num * n
if nextTotal <= N:
ret += process(N, groups+[(num,n)], nextTotal, num+1, B, C, D)
return ret
print(process(N, [], 0, A, B, C, D)) |
s604290604 | p03832 | u280667879 | 1484705612 | Python | PyPy3 (2.4.0) | py | Runtime Error | 211 | 38384 | 306 | N,A,B,C,D=map(int,raw_input().split());Z=[1]+[0]*N;M=10**9+7;I=[1,1];F=I+[];R=I+[]
for i in range(2,N+1):I+=[(M-M/i)*I[M%i]%M];F+=[i*F[-1]%M];R+=[I[i]*R[-1]%M]
for i in range(A,B+1):Z=[(Z[j]+sum(Z[j-i*k]*F[N-j+i*k]*R[N-j]*pow(R[i],k,M)*R[k]for k in range(C,min(D,j/i)+1)))%M for j in range(N+1)]
print Z[N] |
s781377391 | p03833 | u490642448 | 1596243736 | Python | PyPy3 (7.3.0) | py | Runtime Error | 393 | 290228 | 458 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import gc
def main():
n,m = map(int,readline().split())
a = list(map(int,readline().split()))
a += [0,0,0]
b = list(map(int,read().split()))
imos = [[0] * (n+2) for _ in range(n+2)]
left = [0] * (n+2)
right = [0] * (n+2)
bi = [[0,0] for _ in range(n)]
print(ans)
if __name__ == '__main__':
main() |
s483017525 | p03833 | u490642448 | 1595448716 | Python | PyPy3 (7.3.0) | py | Runtime Error | 543 | 453612 | 1265 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from array import array
n,m = map(int,readline().split())
a = list(map(int,readline().split()))
a += [0,0,0]
b = list(map(int,read().split()))
# imos = [[0] * (n+2) for _ in range(n+2)]
imos = array('i', [0]*((n+2)**2))
for i in range(m):
left = list(range(-1,n+1))
right = list(range(1,n+3))
bi = [(val,j) for j,val in enumerate(b[i::m], 1)]
bi.sort()
for val,j in bi:
l = left[j]
r = right[j]
imos[(l+1)*(n+2)+j] += val
imos[(l+1)*(n+2)+r] -= val
imos[(j+1)*(n+2)+j] -= val
imos[(j+1)*(n+2)+r] += val
# imos[l+1][j] += val
# imos[l+1][r] -= val
# imos[j+1][j] -= val
# imos[j+1][r] += val
right[l] = r
left[r] = l
for i in range(n+1):
for j in range(1,n+1):
imos[i*(n+2)+j] += imos[i*(n+2)+j-1]
# imos[i][j] += imos[i][j-1]
for i in range(1,n+1):
for j in range(n+1):
imos[i*(n+2)+j] += imos[(i-1)*(n+2)+j]
# imos[i][j] += imos[i-1][j]
ans = 0
for i in range(1,n+1):
dif = 0
for j in range(i,n+1):
ans = max(ans,imos[i*(n+2)+j] - dif)
dif += a[j-1]
print(ans) |
s060310643 | p03833 | u462329577 | 1594428275 | Python | PyPy3 (7.3.0) | py | Runtime Error | 96 | 74520 | 93 | a, b = map(str, input(), split())
if a.lower() == b:
print("Yes")
else:
print("No")
|
s453987219 | p03833 | u462329577 | 1593719118 | Python | PyPy3 (7.3.0) | py | Runtime Error | 88 | 74840 | 1225 | #!/usr/bin/env python3
# input
deck = input()
SHDC = [[0] * 5 for _ in range(4)] # それぞれのマークの10~12が出たかを管理
pos = 0
Mark = "SHDC"
Flash = ["10", "J", "Q", "K", "A"]
remove_mark = ""
while True:
if deck[pos + 1] in Flash or 50 <= ord(deck[pos + 1]) <= 57:
mark = deck[pos]
num = deck[pos + 1]
pos += 2
elif deck[pos + 2] in Mark:
mark = deck[pos]
num = deck[pos + 1]
pos += 2
else:
mark = deck[pos]
num = deck[pos + 1 : pos + 3]
pos += 3
if num in Flash:
SHDC[Mark.index(mark)][Flash.index(num)] = 1
if sum(SHDC[Mark.index(mark)]) == 5:
remove_mark = mark
break
ans = ""
cnt = 0
while True:
if deck[pos + 1] in Flash or 50 <= ord(deck[pos + 1]) <= 57:
mark = deck[pos]
num = deck[pos + 1]
pos += 2
elif deck[pos + 2] in Mark:
mark = deck[pos]
num = deck[pos + 1]
pos += 2
else:
mark = deck[pos]
num = deck[pos + 1 : pos + 3]
pos += 3
if mark == remove_mark and num in Flash:
ans += mark + num
else:
cnt += 1
if cnt == 5:
break
print(ans)
|
s682110266 | p03833 | u462329577 | 1593655002 | Python | PyPy3 (7.3.0) | py | Runtime Error | 100 | 74760 | 303 | #!/usr/bin/env python3
# input
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
ans += min(b, a * (x[i + 1] - x[i]))
print(ans)
|
s919076424 | p03833 | u102461423 | 1572153250 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38384 | 1370 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,M = map(int,readline().split())
A = [0]+list(map(int,readline().split()))
B = list(map(int,read().split()))
for i in range(1,N):
A[i] += A[i-1]
ticket_sum = [0]*(N*N)
# 各区間 [L,R] に対して、採用される点数を見る
for n in range(M):
arr = B[n::M]
# 安いチケットから入れていく -> 連結成分上で採用される
left = list(range(N))
right = list(range(N))
filled = [False]*(N+1)
for i in sorted(range(N), key=arr.__getitem__):
filled[i] = True
l = i if (not filled[i-1]) else left[i-1]
r = i if (not filled[i+1]) else right[i+1]
left[r] = l; right[l] = r
# [l,i] x [i,r] に arr[i] を加える
x = arr[i]
ticket_sum[l*N+i]+=x
if i<N-1:
ticket_sum[(i+1)*N+i]-=x
if r<N-1:
ticket_sum[l*N+r+1]-=x
if i<N-1:
ticket_sum[(i+1)*N+r+1]+=x
# 2d累積和
for i in range(N,N*N):
ticket_sum[i] += ticket_sum[i-N]
for i in range(N*N):
if i%N:
ticket_sum[i] += ticket_sum[i-1]
answer = 0
for i in range(N):
x = A[i]
for y,t in zip(A[i:],ticket_sum[N*i+i:N*i+N]):
happy = x-y+t
if answer < happy:
answer = happy
print(answer)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.