Problem p02807 (python)

Fixed submission:
# -*- coding: utf-8 -*-

mod = 10**9 +7
N = int(input())
X = list(map(int, input().split()))

factorial=[1]
for i in range(1,N):
    factorial.append(factorial[-1] *i %mod)

ans=0
for i in range(1,N):
    ans = (ans*i + (X[-1]-X[i-1])*factorial[i-1]) %mod

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""

import math,sys
sys.setrecursionlimit(10000)
N = int(input())
X = list(map(int, input().split()))

def calc(n):
    if n==1:
        return 1.0
    return calc(n-1)+(1.0/n)

ev = sum( list( map(lambda i: ((X[i]-X[i-1])*calc(i)), list(range(1,N)) )))

print(int(ev*math.factorial(N-1)%(10**9+7)))
#%(10**9+7)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""

import math,sys
sys.setrecursionlimit(100000)
N = int(input())
X = list(map(int, input().split()))

def calc(n):
    if n==1:
        return 1.0
    return calc(n-1)+(1.0/n)

ev = 0
for i in range(1,N):
    ev += (X[i]-X[i-1])*calc(i)
    if ev >= (10**9+7):
        ev = ev%(10**9+7)

print(int(ev*math.factorial(N-1)%(10**9+7)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""

import math
N = int(input())
X = list(map(int, input().split()))

def calc(n):
    if n==1:
        return 1.0
    return calc(n-1)+(1.0/n)

ev = 0
for i in range(1,N):
    ev += (X[i]-X[i-1])*calc(i)
    if ev>=(10**9+7):
        ev = ev%(10**9+7)

print(int(ev*math.factorial(N-1)%(10**9+7)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(n):
    if n==1:
        return 1.0
    return calc(n-1)+(1.0/n)

ev=0
for i in range(1,N):
    ev += (X[i]-X[i-1])*calc(i)

print(ev*math.factorial(N-1)%(10**9+7))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(j,i):
    if j==i:
        return 1.0/i
    return calc(j+1,i)+(1.0/j)

ev=0
for i in range(1,N):
    ev += (X[i]-X[i-1])*calc(1,i)

print(round(ev*math.factorial(N-1))%(10**9+7))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(j,i):
    if j==i:
        return 1.0/i
    return calc(j+1,i)+(1.0/j)

result = []
for i in range(1, N):
    temp = (X[i]-X[i-1])*calc(1,i)
    result.append(temp)

print(round(sum(result)*math.factorial(N-1))%(10**9+7))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(j):
    l = [1.0/i for i in range(1,j+1)]
    return sum(l)

result = []
for i in range(1, N):
    temp = (X[i]-X[i-1])*calc(i)
    result.append(temp)

print(round(sum(result)*math.factorial(N-1))%(10**9+7))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(i):
    if i==1:
        return 1
    return calc(i-1)+(1.0/i)

result = []
for i in range(1, N):
    temp = (X[i]-X[i-1])*calc(i)
    result.append(temp)
    
print(int(sum(result)*math.factorial(N-1))%(10**9+7))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(i):
    if i==1:
        return 1
    return calc(i-1)+(1.0/i)

result = []
for i in range(1, N):
    temp = (X[i]-X[i-1])*calc(i)
    result.append(temp)
    
print(int(sum(result)*math.factorial(N-1)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(n):
    if n==1:
        return 1
    return calc(n-1)+(1.0/n)

result = []
for i in range(1, N):
    result.append((X[i]-X[i-1])*calc(i))
        
print(int(sum(result)*math.factorial(N-1)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

"""
計算式は以下のように示される
C_n = (1/n)*(1+C_(n-1)) + ((n-1)/n)*C_(n-1)  =  C_(n-1)+(1/n)
"""
import math
N = int(input())
X = list(map(int, input().split()))

def calc(n):
    if n==1:
        return 1
    return calc(n-1)+(1.0/n)

result = []
for i in range(1, N):
    result.append(calc(i))
        
print(sum(result)*math.factorial(N-1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
N = int(input())
X = list(map(int, input().split()))

def solver(N,X):
    r = X[1:]
    result = sum(r)/len(r) * math.factorial(N-1)
    if result>=10**9 +7:
        result = result%10**9 +7
    return int(result)

print(solver(N,X))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
N = int(input())
X = list(map(int, input().split()))

def solver(N,X):
    r = X[1:]
    result = sum(r)/len(r) * math.factorial(N-1)
    return result

print(solver(N,X))