Source
stringclasses
1 value
Date
int64
2.01k
2.02k
Text
stringlengths
22
783k
Token_count
int64
20
394k
Project_CodeNet
2,020
n,k=map(int,input().split()) if k==0: print(n**2);exit() def f(b): return (b-k)*(n//b)+max(0,1+n-(n//b)*b-k) print(sum(f(i)for i in range(k+1,n+1)))
66
Project_CodeNet
2,020
def main(): N, K = map(int, input().split()) ans = 0 for b in range(1, N+1): p = N//b r = N%b ans += p * max(0, b-K) + max(0, r+1-K) - (K==0) print(ans) if __name__ == "__main__": main()
90
Project_CodeNet
2,018
n, k = list(map(int, input().split())) sub = 0 for i in range(1, n+1): s = n//i sub += s*(min(i, k)) sub += min(n%i, max(0, k-1)) print(n**2 - sub)
67
Project_CodeNet
2,020
n,k=map(int,input().split()) ans=0 if k==0: ans=n**2 else: for i in range(k+1,n+1): num2=i-k ans+=(n//i)*num2 ans+=max(0,(n%i)-k+1) print(ans)
71
Project_CodeNet
2,018
N,K = map(int,input().split(" ")) ans = 0 for b in range(K+1,N+1): #for rem in range(K,b): # ans += (N - rem) // b k = ((N - K) // b) num = min(((N - K) % b) + 1,b-K) other = (b - K) - num ans += ((b - K) * (k + 1) - other) if K == 0: print(ans - N) else: print(ans)
119
Project_CodeNet
2,018
n, k = map(int,input().split()) ans = 0 for b in range(1, n + 1): ans += ((n+1)//b)*max(0,b-k) + max(0,((n+1)%b)-k) if k == 0: ans -= 1 print(ans)
73
Project_CodeNet
2,019
N, K =list(map(int, input().split())) answer = 0 for b in range(K+1, N+1): answer += N//b * (b-1 - (K-1)) + max(0, N%b-(K-1)) if K==0: answer -= N print(answer)
72
Project_CodeNet
2,019
n, k = map(int, input().split()) def count(): if k == 0: return n * n c = 0 for i in range(k+1, n+1): c += (n // i) * (i - k) + max((n % i) - k + 1, 0) return c print(count())
83
Project_CodeNet
2,020
n,k=map(int,input().split()) ans=0 for i in range(k+1,n+1): ans+=n//i*(i-k) if n%i>0: if k==0: ans+=n%i else: ans+=max(0,n%i-k+1) #print(ans) print(ans)
76
Project_CodeNet
2,020
def Z(): return int(input()) def ZZ(): return [int(_) for _ in input().split()] def main(): N, K = ZZ() output = 0 for b in range(1, N+1): output += N//b * max(0, b-K) output += max(0, N%b-K+1) if K == 0: output -= 1 print(output) return if __name__ == '__main__': mai...
108
Project_CodeNet
2,020
def main(): n, k = map(int, input().split()) answer = 0 for i in range(1, n + 1): answer += max(0, i - k) * (n // i) + max(0, n % i - k + 1) print(answer if k > 0 else n ** 2) if __name__ == '__main__': main()
90
Project_CodeNet
2,018
N, K = map(int, input().split()) ans = 0 i = K + 1 if K == 0: ans = N * N else: while i <= N: div = N // i ans += max(N % i - K + 1, 0) ans += div * (i - K) i += 1 print(ans)
87
Project_CodeNet
2,020
N,K=map(int,input().split()) ans=0 for b in range(1,N+1): p = N//b r = N%b ans+=p*max(0,b-K) ans+=max(0,r-K+1) if(K==0): ans-=N print(ans)
72
Project_CodeNet
2,019
# a%b >= K iff xb+K <= a < (x+1)b # bごとに数えるだけ N,K = map(int,input().split()) ans = 0 for b in range(K+1,N+1): cnt = 0 x_max = N//b # 0 <= x < x_max # 各xに対してb-K個ある cnt += x_max * (b-K) # x = x_max lower = x_max*b+K if lower <= N: upper = min((x_max+1)*b-1,N) cnt += upper - lower + 1 ans += cn...
178
Project_CodeNet
2,019
N,K = [int(x) for x in input().split()] #%% cnt = 0 if(K==0): print(N**2) else: for i in range(K+1,N+1): x = i-K y = N // i cnt += x*y + max(0,N%i-K+1) print(cnt)
78
Project_CodeNet
2,018
import sys N, K = [int(i) for i in input().split()] if K == 0: print(N**2) sys.exit() ans = 0 for b in range(K,N+1): ans += N//b*(b-K) + max(0, N%b -K+1) print(ans)
74
Project_CodeNet
2,020
n, k = map(int, input().split()) res = 0 if k == 0: print(n*n) exit() for i in range(k+1, n+1): cnt = (i-1)-k+1 add = n // i * cnt if n % i >= k: add += (n % i) - k + 1 res += add print(res)
93
Project_CodeNet
2,020
def solve(): N, K = map(int, input().split()) ans = 0 if K == 0: print(N ** 2) else: for b in range(K + 1, N + 1): a = N // b ans += a * (b - K) ans += max(0, N - (a * b + K) + 1) print(ans) return 0 if __name__ == "__main__": so...
110
Project_CodeNet
2,020
n, k = map(int, input().split()) ans = 0 for i in range(k+1, n+1): d, m = divmod(n, i) ans += d*(i-k) + max(0, m-k+1) - (k==0) print(ans)
66
Project_CodeNet
2,020
# 解説AC N,K = map(int, input().split()) cnt = 0 for b in range(1, N+1): p,r = divmod(N, b) cnt += p * max(0, b - K) cnt += max(0, r - K + 1) # a = 0のとき if K == 0: cnt -= N print(cnt)
92
Project_CodeNet
2,019
n,k=map(int,input().split()) a=0 for b in range(k+1,n+1):a+=(b-k)*(n//b)+max(0,n%b-k+1)-1*(k==0) print(a)
52
Project_CodeNet
2,020
N, K = map(int, input().split()) ans = 0 for b in range(K+1, N+1): q, r = divmod(N, b) ans += q * (b-K) + max(r - K + 1, 0) if K == 0: ans -= 1 #a != 0 #print(ans) print(ans)
86
Project_CodeNet
2,018
def f(b, K, N): i = N // b ans = N - ((K-1) + (i - 1) * K + min((N%b) + 1, K)) return ans N, K = map(int, input().split(' ')) if K == 0: ans = int(N * N) print(ans) else: ans = 0 for b in range(K+1, N+1): ans += f(b, K, N) print(ans)
116
Project_CodeNet
2,020
n, k = (int(x) for x in input().split()) ans = 0 for b in range(k + 1, n + 1): m = n // b ans += m * (b - k) # [k,b) ans += max(0, (n % b) - max(0, k - 1)) print(ans)
82
Project_CodeNet
2,020
N, K = map(int, input().split()) c = 1 ans = 0 if K == 0: print(N*N) else: for i in range(K+1, N+1): ans += c*(N // i) ans += max(N % i - K + 1, 0) c += 1 print(ans)
82
Project_CodeNet
2,019
import sys input = sys.stdin.readline def solve(): n,k =(int(i) for i in input().split()) if n <= k: print(0) exit() else: ans = 0 for b in range(k+1,n+1): if n%b == 0: ans += (n//b)*(b-k) else: if k == 0: ans += (n//b)*(b-k)+n%b else...
139
Project_CodeNet
2,020
N, K = map(int, input().split()) ans = 0 k = K + 1 for i in range(1, N-K+1): ans += i * (N // k) + max(N % k - (K - 1), 0) k += 1 if K == 0: ans = N ** 2 print(ans)
83
Project_CodeNet
2,020
import sys read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): N, K = map(int, readline().split()) ans = 0 for i in range(K + 1, N + 1): ans += N // i * (i - K) if N % i > 0: if K == 0: ...
150
Project_CodeNet
2,020
N,K = map(int,input().split()) if K==0: print(N*N) exit() ans = 0 for b in range(K+1,N+1): d,m = divmod(N+1,b) ans += (b-K)*d ans += max(0, (m-1)-K+1) print(ans)
77
Project_CodeNet
2,020
n, k = map(int, input().split()) ans = 0 for b in range(max(1,k), n+1): ans += n//b * max(0, b-k) + max(0, n%b+1-k) if k == 0: ans -= 1 print(ans)
70
Project_CodeNet
2,018
def main(): n, k = map(int, input().split()) if k == 0: print(n * n) return c = 0 for b in range(k + 1, n + 1): c += n // b * (b - k) + max(n % b - k + 1, 0) print(c) if __name__ == '__main__': main()
93
Project_CodeNet
2,020
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,k = list(map(int, input().split())) ans = 0 for b in range(k+1, n+1): val = (b-k) * (n//b) + max(0, (n%b)-k+1) if k==0: val -= 1 ans += val # print(b,v...
121
Project_CodeNet
2,020
n, k = [int(i) for i in input().split()] ans = 0 if k == 0: ans = n*n else: for b in range(k+1, n+1): # number of perfect cycle ans += n // b * (b-k) r = n % b ans += max(r - k+1, 0) print(ans)
88
Project_CodeNet
2,018
n,k = map(int,raw_input().split()) ans = 0 if k == 0 : print n*n else: for i in range(1,n+1): ans += n/i * max(0,i-k) + max(0,n%i-k+1) print ans
62
Project_CodeNet
2,019
N, K = map(int, input().split()) ans = 0 for b in range(K+1,N+1): if N%b==0: ans += (N//b)*(b-K) else: ans += (N//b)*(b-K)+max(N%b-K+1,0) if K!=0 else (N//b)*(b-K)+(N%b) # print(ans) print(ans)
95
Project_CodeNet
2,019
n,k=map(int,input().split());print(sum(n//b*(b-k)+max(n%b-k+(k>0),0)for b in range(k+1,n+1)))
41
Project_CodeNet
2,020
def examC(): N = LI(); N.sort() if N[0]==1: if N[1]==1: ans = 1 else: ans = max(0,N[1]-2) else: ans = (N[1]-2)*(N[0]-2) print(ans) return def examD(): N, K = LI() ans = 0 b = K+1 while(b<=N): cur = N//b * (b-K) + max(0,N%b - K+...
360
Project_CodeNet
2,018
def solve(): N, K = map(int, input().split()) res = 0 for b in range(K+1, N+1): res += b-K res += (N//b - 1) * (b-K) res += (N%b)-K+1 if N%b >= K else 0 if K == 0: res -= N print(res) if __name__ == "__main__": solve()
104
Project_CodeNet
2,020
#template from collections import Counter def inputlist(): return [int(k) for k in input().split()] #template N,K = inputlist() if K == 0: print(N**2) exit() ans = 0 for i in range(K+1,N+1): indexa = i-K sub = N-i+1 ans += indexa if sub // i != 0: ans += (sub//i)*indexa mod = sub % ...
125
Project_CodeNet
2,020
from itertools import permutations import sys sys.setrecursionlimit(10 ** 6) from bisect import * from collections import * from heapq import * def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): ret...
260
Project_CodeNet
2,020
N, K = map(int, input().split()) ans = 0 b = K+1 while b <= N: p = N//b r = N%b ans += p*max(0,b-K)+max(0, r-K+1)-(0 if K > 0 else 1) b += 1 print(ans)
80
Project_CodeNet
2,019
n,k = map(int,input().split()) t = 0 for b in range(k+1,n+1): p,q = divmod(n,b) t += p*max(0,b-k) + max(0,q-k+1) if k == 0: t -= n print(t)
68
Project_CodeNet
2,020
import sys def solve(x): return (x - k) * (n // x) + max(0, n % x - k + 1) n, k = map(int, input().split()) if k == 0: print(n**2) sys.exit() ans = 0 for i in range(k + 1, n + 1): ans += solve(i) print(ans)
89
Project_CodeNet
2,020
from _collections import deque from _ast import Num def parser(): while 1: data = list(input().split(' ')) for number in data: if len(number) > 0: yield (number) input_parser = parser() def gw(): global input_parser return next(input_parser) def gi(): ...
244
Project_CodeNet
2,020
N,K = map(int,input().split()) ans = 0 for b in range(K+1,N+1): ans += (b-K)*(int(N//b)) last = int(N//b) if b*last + K <= N: ans += N- (b*last+K) +1 if K == 0: ans -= 1 print(ans)
86
Project_CodeNet
2,018
import sys def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline def main(): if len(sys.argv) > 1: f = open(sys.argv[1]) else: f = None read_func = get_read_func(f); input_raw = read_func().strip().split() [N...
204
Project_CodeNet
2,019
n,k=map(int,input().split()) a=(n-k)*(n-k+1)//2 for i in range(k+1,n): j=n//i*i a+=(j//i-1)*(i-k)+max(n-j+1-max(k,1),0) print(a)
64
Project_CodeNet
2,018
def solve1(): n, k = map(int, input().split()) ans = 0 for i in range(1, n+1): for j in range(1, n+1): if i % j >= k: ans += 1 print(ans) def solve(): n, k = map(int, input().split()) # k0は例外処理 if k == 0: print(n**2) return # 割る数B...
307
Project_CodeNet
2,020
n,k = map(int,input().split()) ans = 0 if k > 0: for i in range(k+1,n+1): a = n // i b = n % i ans += (a * (i-k) + (max(0,b-(k-1)))) else: ans = n ** 2 print(ans)
80
Project_CodeNet
2,018
# cook your dish here n,k = map(int,input().split()) ass = 0 for i in range(k+1,n+1): jkl = ass ass += (i-1)-k+1 w = (n-(i-1))//i if w >= 1: ass += ((i-1)-k+1)*w r = n-(w+1)*i if r >= k: ass += r-k+1 #print(i,ass-jkl) if k ==0: print(n**2) else: print(ass)
135
Project_CodeNet
2,020
N, K = map(int, input().split()) ans = 0 for b in range(1, N+1): p = N // b r = N % b ans += max(0, b - K) * p + max(0, r - K + 1) if K == 0: ans -= 1 print(ans)
82
Project_CodeNet
2,020
N, K = map(int, input().split()) ans = 0 for b in range(1, N+1): p = N // b r = N % b ans += p * max(0, b - K) ans += max(0, r - K + 1) if K == 0: ans -= N print(ans)
82
Project_CodeNet
2,020
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator ...
265
Project_CodeNet
2,020
import sys # sys.setrecursionlimit(100000) def input(): return sys.stdin.readline().strip() def input_int(): return int(input()) def input_int_list(): return [int(i) for i in input().split()] def main(): n, k = input_int_list() ans = 0 if k == 0: print(n * n) return #...
184
Project_CodeNet
2,019
import sys n,k=map(int,input().split()) if k==0: print(n**2) sys.exit() ans=0 for i in range(k+1,n+1): ans+=(n//i)*(i-k) if n%i>=k: ans+=n%i-k+1 print(ans)
71
Project_CodeNet
2,018
N, K = map(int, input().split(" ")) retSum = 0 for b in range(K+1, N+1): q = N // b r = N - q * b if r >= K and r != 0: if r == K: retSum += 1 else: if K == 0: retSum += r - K else: retSum += r - K + 1 retSum += q * (b - K) print(retSum)
115
Project_CodeNet
2,019
def main(): n, k = map(int, input().split()) res = 0 for b in range(k + 1, n + 1): tail = max(0, (n % b) - k + 1) body = (b - k) * (n // b) res += body + tail - (k == 0) print(res) if __name__ == "__main__": main()
96
Project_CodeNet
2,018
import sys N, K = map(int, raw_input().split()) if K == 0: print N * N sys.exit() ans = 0 for i in range(K + 1, N+1): ans += max(N % i - K + 1, 0) + (N / i) * (i - K) print ans
80
Project_CodeNet
2,020
n,k = [int(i) for i in input().split()] ans = 0 for i in range(k+1,n+1): m = (n+1)//i ans += (i-k)*m if m*i+k <= n: ans += (n+1-m*i-k) if k == 0: ans -= n print(ans)
82
Project_CodeNet
2,020
# all n integers can be divided into blocks of integers of size i and in each # there will be total i-k integers which has remainder greater than k so we multiply this with no of blocks # if there is a last block remaining we add all integers with remainder greater than k def main(): n , k = map(int , input().split(...
154
Project_CodeNet
2,020
n, k = map(int, input().split()) ans = 0 for b in range(k+1, n+1): ans += n//b * (b-k) ans += max((n%b)-k+1, 0) if k == 0: # ans -= n ans = n*n print(ans)
76
Project_CodeNet
2,020
# https://atcoder.jp/contests/arc091/tasks/arc091_b n, k = map(int, input().split()) ans = 0 for i in range(1, n + 1): surplus = n // i quotient = n % i ans += surplus * max(0, i - k) + max(0, quotient - k + 1) print(ans if k != 0 else ans - n)
97
Project_CodeNet
2,020
n,k=map(int,input().split()) ans=0 for mod in range(1,n+1): ans+=(n//mod)*max(0,mod-k) ans+=max(0,n%mod-k+1) if k>0 else n%mod print(ans)
62
Project_CodeNet
2,020
def main(): N, K = (int(i) for i in input().split()) if K == 0: return print(N**2) ans = 0 for b in range(2, N+1): if K > b-1: continue pat = N//b ans += pat*(b-K) m = N % b if K <= m: ans += m-K+1 print(ans) if __name__ == '_...
113
Project_CodeNet
2,020
n,k=map(int,input().split()) if k==0: print(n**2) else: ans=0 for b in range(1,n+1): ans+=n//b*max(0,b-k) ans+=max(0,n%b-k+1) print(ans)
68
Project_CodeNet
2,019
n, k = map(int, input().split()) ans = 0 for b in range(k + 1, n + 1): ans += (n // b) * (b - k) + max((n % b) - k + 1, 0) if k == 0: print(ans - n) else: print(ans)
78
Project_CodeNet
2,020
def f(n, m, k): return (n + 1) // m * (m - k) + max(0, (n + 1) - (n + 1) // m * m - k) - (1 if k == 0 else 0) n, k = [int(x) for x in input().split()] print(sum(f(n, m, k) for m in range(k + 1, n + 1)))
99
Project_CodeNet
2,020
n,k=map(int,input().split()) ans=0 for b in range(1,n+1): p=n//b r=n-p*b ans+=p*max(b-k,0)+max(0,r-k+1) if k==0: ans-=n print(ans)
67
Project_CodeNet
2,020
n,k = map(int,input().split()) result = 0 for b in range(k+1,n+1): roop = n //b roop_ok = (b-1) - (k-1) amari = n % b amari_ok = amari - k + 1 if roop_ok >= 0 : result += roop * roop_ok if amari_ok > 0 : result += amari_ok if k == 0: print(n**2) else: print(result)
126
Project_CodeNet
2,019
n,k=map(int,input().split()) if k==0: ans=n*n else: ans=0 for i in range(k,n+1): ans+=(i-k)*(n//i) if n%i>=k: ans+=(n%i)-k+1 print(ans)
66
Project_CodeNet
2,020
def num_divisors_cnt(n): table = [0] * (n + 1) for i in range(1, n+1): for j in range(i, n + 1, i): table[j] += 1 return table def main(): N, K = map(int, input().split()) ans = 0 for i in range(K+1,N+1): cnt = i - K cnt *= N // i cnt +...
155
Project_CodeNet
2,020
n,k=map(int,input().split()) b=[i for i in range(k+1,n+1)] ans=0 if k==0: for i in range(len(b)): t=b[i] j=t-k ii=n//t ans+=ii*j ans+=max(n-ii*t-k,0) print(ans) exit() for i in range(len(b)): t=b[i] j=t-k ii=n//t ans+=ii*j ans+=max(n-ii*t-k+1,0) pr...
127
Project_CodeNet
2,019
n, k = map(int, input().split()) ans = 0 for b in range(1, n+1): p = n // b r = n - p*b ans += p*(max(0, b-k)) + max(0, r-k+1) if k == 0: ans -= n else: pass print(ans)
83
Project_CodeNet
2,018
# coding: utf-8 # Your code here! N,K=[int(i) for i in input().split()] num = 0 if K==0: print(N*N) else: for b in range(K+1,N+1): num += (b-K)*(N//b) + max(0,N%b-(K-1)) print(num) #nnn=0 #for a in range(1,N+1): # for b in range(1,N+1): # if a%b >= K: # nnn+=1 #print(nnn) ...
130
Project_CodeNet
2,020
N, K = map(int, input().split()) ans = 0 if K == 0: ans = N * N else: for b in range(1, N + 1): div, mod = divmod(N, b) ans += max(0, b - K) * div ans += max(0, mod - K + 1) print(ans)
86
Project_CodeNet
2,018
N,K = list(map(int, input().split())) # K b = K+1~N,a = ib+K total:sigma((N-k)//b+1) if K==0: print(N*N) else: ans = 0 for b in range(K+1, N+1): ans += (N//b) * (b-K) + max(0, (N%b) - (K-1)) print(ans)
100
Project_CodeNet
2,019
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N, K = map(int, input().split()) ans = 0 if K == 0: ans = N*N else: for b in range(K+1, N+1): ans += (N//b)*(b-K) r = N % b ans += max(0, r-K+1) print(ans)
103
Project_CodeNet
2,018
n,k = map(int, input().split()) ans = 0 for p in range(k+1, n+1): if (n//p * p) + k <= n: ans += n - (n//p) * p - k + 1 ans += n//p * (p-k) if k == 0: ans -= n print(ans)
84
Project_CodeNet
2,020
N, K = map(int, input().split(' ')) ans = 0 for b in range(1, N+1): ans += max(b - K, 0) * (N // b) ans += max((N%b) - K + 1, 0) if K == 0: ans -= N print(ans) # ans = 0 # for b in range(1, N+1): # for k in range(K, b): # for a in range(k, N+1, b): # if a > 0: # ...
162
Project_CodeNet
2,018
#!/usr/bin/python # -*- coding: utf-8 -*- import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq # decimal.getcontext().prec = 50 # sys.setrecursionlimit(10000) # MOD = 10**9 + 7 def solve(f): n, k = f.read_int_list() if k == 0: return n**2 ans = 0 for b in xrange(k+1, n+...
450
Project_CodeNet
2,020
N, K = map(int, input().split()) rlt = 0 for b in range(K+1, N+1): if K > 0: rlt += (N//b)*(b-K) + max(0, N%b - K +1) else: rlt += (N//b)*(b-K) + max(0, N%b) print(rlt)
92
Project_CodeNet
2,018
N, K = map(int, input().split()) result = 0 if K == 0: result = N * N else: for i in range(K+1, N+1): result += (N//i * (i - K) + max(N%i-K+1, 0)) print(result)
71
Project_CodeNet
2,020
n, k = [int(i) for i in input().split()] ans = 0 if k == 0: ans = n ** 2 else: for b in range(1, n+1): if b > k: loop_num = n // b #繰り返し回数 loop_last = n - loop_num * b #ラストの途中で途切れてる部分 ans += (b-k) * loop_num + max(0, loop_last - k + 1) print(ans)
126
Project_CodeNet
2,019
n, k = map(int,input().split()) a=0 for i in range(1,n+1): a+=max(0,i-k)*(n//i)+max(0,n%i-k+1) if k==0: a-=n print(a)
59
Project_CodeNet
2,020
n,k = map(int, input().split()) ans = 0 if k == 0: print(n**2) exit() for b in range(k+1, n+1): ans += (n//b) * (b-k) ans += max(0, n-(n//b)*b-k+1) print(ans)
76
Project_CodeNet
2,020
N, K = map(int, input().split()) if K == 0: print(N ** 2) else: ans = 0 for b in range(K + 1, N + 1): n_groups = N // b rest = N % b ans += n_groups * (b - K) + max(0, rest - K + 1) print(ans)
89
Project_CodeNet
2,020
import sys input_methods=['clipboard','file','key'] using_method=0 input_method=input_methods[using_method] tin=lambda : map(int, input().split()) lin=lambda : list(tin()) mod=1000000007 #+++++ def dd(b, n, k): if k==0: return n if b <= k: return 0 ret = 0 na = n // b ret += na * (b-k) nb = n % b ret +...
330
Project_CodeNet
2,019
n, k = gets.strip.split.map(&:to_i) result = 0 (1..n).each do |b| result += ( (n/b) * [(b-k), 0].max + [(n%b)-k+1, 0].max ) end result -= n if k==0 p result
71
Project_CodeNet
2,018
N, K = gets.chomp.split(" ").map(&:to_i) if K == 0 puts N**2 else puts (K+1..N).map{ |b| (b-K) * (N/b) + [((N%b)-K+1), 0].max }.inject(:+) end
73
Project_CodeNet
2,018
N,K = gets.split.map(&:to_i) if K == 0 p N*N exit end ans = 0 (K+1).upto(N) do |b| # a % b #cnt = b - K cnt = (b-K)*(N/b) cnt += [N-N/b*b-K+1, 0].max ans += cnt # +plus... end p ans
99
Project_CodeNet
2,020
n,k = gets.split.map &:to_i solve = -> b { q,r = (n + 1).divmod(b) ans = q * [b - k, 0].max ans += [r - k, 0].max k == 0 ? ans - 1 : ans } ans = 0 1.upto(n) do |i| ans += solve[i] end puts ans
96
Project_CodeNet
2,020
N,K=gets.chomp.split(" ").map(&:to_i) ret=0 if K==0 puts N*N exit end ((K+1)..N).each do |b| n=(N+1)/b ret+=(b-K)*n rest=N-n*b if rest-K+1 > 0 ret+= rest-K+1 end end puts ret
93
Project_CodeNet
2,020
n,k=gets.split.map(&:to_i) if k==0 puts n**2 exit end c=0 (k+1).upto(n) do |i| c+=(n+1)/i*(i-k)+((n+1)%i>k ? (n+1)%i-k : 0) end puts c
78
Project_CodeNet
2,018
n,k = gets.split.map(&:to_i) if k==0 p n*n exit end ans = 0 (k+1).upto(n){|b| ans += (n/b)*(b-k)+[n%b-k+1,0].max } p ans
66
Project_CodeNet
2,020
def get_i() #空白区切の入力を数値(整数)の配列で返す return gets.chomp.split(" ").map(&:to_i) end def get_f() #空白区切の入力を数値(実数)の配列で返す return gets.chomp.split(" ").map(&:to_f) end def get() #空白区切の入力を文字列の配列で返す return gets.chomp.split(" ") end def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す return gets.chomp.split("") end def yn_judge(bool...
449
Project_CodeNet
2,018
N,K=gets.chomp.split(' ').map{|n| n.to_i} sum = 0 if(K==0) puts N*N exit(0) end K.upto(N){|b| q = N/b r = N-q*b-(K-1) r = 0 if r < 0 dif = (b-(K))*q + r sum += dif # puts "bqr #{b}, #{q}, #{r}, sum+=#{dif}" } puts sum
110
Project_CodeNet
2,020
N,K=$<.read.split.map(&:to_i) if K == 0 puts N*N exit end ret = 0 2.upto(N) do |i| x = [i-K,0].max r,q = N.divmod(i) # p [r,q, r * x, [q-K+1,0].max] ret += r * x + [q-K+1,0].max end puts ret # arr = Array.new(N) { Array.new(N,0) } # N.times do |i| # N.times do |j| # arr[i][j] = (i...
196
Project_CodeNet
2,018
n,k = gets.chomp.split.map(&:to_i) count = 0 if k==0 count = n*n else (k+1..n).each do |b| rem = n%b if rem >= k count += (b-k)*(n/b) + rem + 1 - k else count += (b-k)*(n/b) end end end printf("%d\n",count)
101
Project_CodeNet
2,018
n, k = gets.split.map{|v| v.to_i } if k == 0 then p n * n exit end ans = 0 for b in (k+1)..n ans += (n / b) * (b - k) + [0, (n % b) - k + 1].max end p ans
85
Project_CodeNet
2,018
n, k=gets.split.map(&:to_i) ret=0 1.upto n do |b| m=(n+1)/b ret+=[b-k, 0].max*m l=n+1-m*b ret+=[l-k, 0].max end ret-=n if k==0 puts ret
78