Problem:


Score : 300 points

Problem Statement

Given is a positive integer N.
How many tuples (A,B,C) of positive integers satisfy A \times B + C = N?

Constraints

 2 \leq N \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

3

Sample Output 1

3

There are 3 tuples of integers that satisfy A \times B + C = 3: (A, B, C) = (1, 1, 2), (1, 2, 1), (2, 1, 1).

Sample Input 2

100

Sample Output 2

473

Sample Input 3

1000000

Sample Output 3

13969985



Sample input:
3


Sample output:
3

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def make_divisors(n):
    divisors = []
    # 試し割りで、かつ積でnを作るときの相方も同時に追加してる
    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

ans = 0
for c in range(1,N):
    p = N-c
    div_ls = make_divisors(p)
    ans += len(div_ls)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
ans = 0
n = int(input())
for i in range(1,n+1):
  for j in range(1,n//i+1):
    if i * j < n:ans += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    ans+=(n-1)//i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ar=0
for i in range(1,n+1):
  ar+=(n-1)//i
print(ar)

Submission status: Accepted

Solution code:
n=int(input())
ar=3
sv=[0]*(10**6+2)
for i in range(2,len(sv)):
	if not sv[i]:
		sv[i]=i
		for j in range(2*i,len(sv),i):
			sv[j]=i
def di(x):
  an=1
  if sv[x]==x:
    return 2
  while x>1:
    ct=0;cr=sv[x]
    while x%cr==0:
      ct+=1;x//=cr
    an*=(ct+1)
  return an
for i in range(4,n+1):
  ar=ar+di(i-1)
if n==2:
  ar=1
print(ar)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for a in range(1,n):
    ans+=(n-1)//a
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1,N):
    if N%i == 0:
        ans += N//i-1
    else:
        ans += N//i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans =0

for i in range(1,n):
    ans +=(n-1)//i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0

for a in range(1, N):
    cnt += int((N - 1) / a)

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for a in range(1, N):
    ans += int((N - 1) / a)
print(ans)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()

ans = 0
for a in range(1,n):
    ans += (n-1)//a        

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for a in range(1, n):
  ans += (n-1) // a
  
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.buffer.readline

N = int(input())
tmp = 0

for a in range(1,N):
    tmp = tmp + (N-1) // a
    
print(tmp)

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for i in range(1,n):
    count += (n-1) // i
print(count)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for a in range(1,n+1):
  ans+=(n-1)//a
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for a in range(1,N):
    ans += (N-1)//a

print("{}".format(ans))

Submission status: Accepted

Solution code:

N = int(input())

ans = 0
for a in range(1, 10 ** 6 + 1):
    for b in range(1, 10 ** 6 + 1):
        if a * b >= N:
            break
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0

Ru = int(N**0.5)

for i in range(N):
  ans += N//(i+1)
  if N%(i+1)==0:
    ans -= 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n):
	ans+=(n-1)//i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for a in range(1, n):
    # n-1 なのは a で割り切れたときに c が正整数であるため
    ans += (n-1) // a

print(ans)

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline().strip())

# A * B + C, make sure A * B <= N, if A == B, it is (N-A*B) + 1, else ((N-A*B) + 1) * 2
res = 0
"""
for i in range(1, n//2+1):
    if i ** 2 < n:
        res += 1
    for j in range(i+1, n//i+1):
        if i*j >= n:
            break
        res +=  2

print(res)
"""

# A==B, from 1 to square root
res += int(n**0.5)
upperbound = int(n**0.5) + 1
if int(n**0.5) ** 2 == n:
    # n has int square root
    res -= 1
    upperbound = int(n**0.5)

# Assuming A < B
# A = 1, B=2...N-1
# A = 2, B=3...N/2 or N/2-1

for i in range(1, upperbound):
    if n % i == 0:
        half = n // i - 1 - i
    else:
        half = n//i - i
    res += half * 2
print(res)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for a in range(1,n):
  ans += (n-1)//a
print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    ans = 0
    for a in range(1, 10**3+1):
        if a ** 2 >= N:
            continue
        b_num = N // a - a
        if a * (N // a) == N:
            b_num -= 1
        ans += b_num
    ans *= 2
    ans += int(math.sqrt(N))
    if int(math.sqrt(N)) ** 2 == N:
        ans -= 1
    print(ans)
main()

Submission status: Accepted

Solution code:
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
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
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
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
mod = 10**9 + 7

#maincode-------------------------------------------------

n = int(input())
ans = 0
for i in range(1,n):
    ans += int((n-1)/i)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
n-=1
ans = 0
for x in range(1, n+1):
    ans += n//x
print(ans)

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
ans = 0
for i in range(1, n):
    ans += (n-1) // i
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
for a in range(1,N):
    q,m=divmod(N,a)
    ans+=(N//a)-(m==0)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for i in range(n-1):
    if n%(i+1)==0:
        ans += n//(i+1)-1
    else:
        ans += n//(i+1)

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
  
def f(i):
  if n%i==0:
    return n//i-1
  else:
    return n//i

sum=0
for i in range(1,n):
  sum+=f(i)

print(sum)

Submission status: Accepted

Solution code:
N=int(input())
count=0
for A in range(1,N):
  count+=(N-1)//A
print(count)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1, n):
    ans += (n - 1) // i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
print(sum((n-1)//a for a in range(1, n)))

Submission status: Accepted

Solution code:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
ans = 0

for A in range(1, N):
    for B in range(1, N // A + 1):
        if N - A * B < 1:
            break
        ans += 1
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
for a in range(1, N):
    cnt += (N-1)//a
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(1, N):
    for j in range(1, N):
        if i * j < N:
            ans += 1
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for a in range(1,n+1):
    ans += (n-1)//a
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
count=0
for i in range(n):
    count+=((n-1)//(i+1))
print(count)

Submission status: Accepted

Solution code:
n = int(input())
i,j=1,1
count=0

x = i*j
cc = n-x

while cc>=1:

	cnt=0
	while 1:
		p = i*j
		c = n - p
		if c>=1:
			#print(i,":",j,":",c)
			j=j+1
			cnt+=1
		else:
			j=i
			break

	count=count+((cnt*2)-1)

	i=i+1
	j=j+1

	x = i*j
	cc = n-x


print(count)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

res = 0
for a in range(1, N):
    res += (N - 1) // a
print(res)

Submission status: Accepted

Solution code:
N = int(input())
nd = [0] * (N+1)
for i in range(1, N):
    for j in range(i, N, i):
        nd[j] += 1
print(sum(nd))

Submission status: Accepted

Solution code:
N=int(input())
s=0
for i in range(1,N+1):
  s+=int(N/i)
  if N%i==0:
    s-=1
print(s)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1,N):
    #print((N-0.5)//i)
    ans += (N-1) // i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for a in range(1, n):
    count += (n - 0.5) // a
print(int(count))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    ans = 0
    for i in  range(1, N):
        ans += (N-1)//i
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for A in range(1, N):
  ans += (N-1)//A
  
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for A in range(1, N+1):
  ans += (N-1)//A
  
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
n=N-1
ans=1
for a in range(1,n):
    ans+=n//a
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
c = 0

for i in range(1, n):
    c += (n-1) // i

print(c)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n):
    ans+=(n-1)//i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0 
for a in range(1, n):
   ans += (n - 1) // a 
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for i in range(N):
    count += int((N-1)/(i+1))
print(count)

Submission status: Accepted

Solution code:
import math

N = int(input())

result = 0
n = math.sqrt(N)
n = math.ceil(n)

for i in range(1, n + 1):
    for j in range(i, N // i + 1):
        if i * j < N:
            if i == j:
                result += 1
            else:
                result += 2
        else:
            break
print(result)

Submission status: Accepted

Solution code:
N=int(input())
ans=[]
for i in range(1,N):
    temp=(N-1)//i
    ans.append(temp)
Ans=sum(ans)
print(Ans)

Submission status: Accepted

Solution code:
n = int(input())
D = [0] * n
for i in range(1, n):
    for j in range(i, n, i):
        D[j] += 1
print(sum(D))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for a in range(1,n):
    for b in range(1,n):
        c = n-a*b
        if c <= 0:
            break
        ans += 1


print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
ans = 0
for i in range(1, N):
    ans += (N-1)//i
print(ans)

Submission status: Accepted

Solution code:
ans = 0
n = int(input().rstrip())
for i in range(1, n):
  ans += (n-1)//i
print(ans)

Submission status: Accepted

Solution code:
# coding:UTF-8
import sys
from math import factorial, ceil, floor

MOD = 10 ** 9 + 7
INF = 10000000000


def main():
    # ------ 入力 ------#
    n = int(input())    # 数字

    # ------ 処理 ------#
    result = 0
    for a in range(1, n+1):
        tmp = (n - 1) // a
        result += tmp

    # ------ 出力 ------#
    print("{}".format(result))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for a in range(1, n):
    ans += (n - 1) // a
print(ans)

Submission status: Accepted

Solution code:
def func(N):
  result = 0

  for A in range(1,N):
    result += (N-1)//A

  return result

if __name__ == "__main__":
    N = int(input())
    print(func(N))

Submission status: Accepted

Solution code:
n=int(input())

cnt=0
for i in range(1,n):
    cnt +=(n-1)//i
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
count_eq = 0
count_df = 0
for i in range(1,N):
  for j in range(i,N):
    if i*j <= N-1:
      if i == j:
        count_eq += 1
      else :
      	count_df += 1
    else :
      break
print(count_eq + 2*count_df)

Submission status: Accepted

Solution code:
N=int(input())
count=0
for a in range(1, N):
  count+=(N-1)//a
print(count)

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for a in range(1,N+1):
  for b in range(a,N//a+1):
    if a * b < N:
      if a == b:
        count += 1
      else:
        count += 2
print(count)

Submission status: Accepted

Solution code:
N=int(input())
s=0
for i in range(1,N):
  s+=(N-1)//i
print(s)

Submission status: Accepted

Solution code:
N=int(input())
s=0
for i in range(1,N):
  s+=(N-0.1)//i

print(int(s))

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1, n):
    ans += (n-1)//i

print(ans)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
n = onem()

co = 0

for i in range(1,n):
    po = n // i
    co += po
    if i * po == n:
        co -= 1
print(co)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1, n):
    ans += n//i if n%i != 0 else n//i-1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N):
    ans += (N - 1) // i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for a in range(1, n):
    ans += (n - 1) // a
print(ans)

Submission status: Accepted

Solution code:
ln=10**6+10
sieve=[i for i in range(ln)]
p=2
while p**2<=ln:
  if sieve[p]==p:
    for q in range(p*2,ln,p):
      if sieve[q]==q:
        sieve[q]=p
  p+=1
import collections
def primef(n):
  prime_count=collections.Counter()    
  while n>1:
    prime_count[sieve[n]]+=1
    n//=sieve[n]   
  return prime_count
n=int(input())
ans=0
for i in range(1,n):
  t=1
  for j in primef(i).values():
    t=t*(j+1)
  ans+=t
print(ans)

Submission status: Accepted

Solution code:
n=int(input())-1
ans=0
for i in range(1,n+1):
  ans+=n//i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
a=1
while(a*a<n):
    cnt+=1
    cnt+=max((n-1)//a-a,0)*2
    a+=1
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
a=1
while(a*a<n):
    cnt+=1
    a+=1
a=1
while(a*a<n):
    cnt+=max((n-1)//a-a,0)*2
    a+=1
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
for a in range(1,n):
    cnt+=(n-1)//a
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())

def num_divisors_table(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

l=num_divisors_table(N-1)
print(sum(l))

Submission status: Accepted

Solution code:
from math import sqrt
N = int(input())
ans = 0
for a in range(1, N+1):
    ans += (N-1)//a

print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    N = int(input())
    for i in range(1, N):
        ans += (N-1)//i
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
for a in range(1, N):
    n = (N - 1) // a
    cnt += n

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for n in range(1,N):
  ans += int((N-1)/n)
print(ans)

Submission status: Accepted

Solution code:
def solve():
    ans = 0
    for a in range(1, N):
        for b in range(1, N):
            c = N - a * b
            if c <= 0:
                break
            ans += 1
    return ans


N = int(input())
ans = solve()
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for a in range(1, N):
  ans += (N - 1) // a
print(ans)

Submission status: Accepted

Solution code:
# Python3 implementation of the approach
# Function to find the number of divisors
# of all numbers in the range [1,n]
def findDivisors(n):
    # List to store the count
    # of divisors
    div = [0 for i in range(n + 1)]

    # For every number from 1 to n
    for i in range(1, n + 1):

        # Increase divisors count for
        # every number divisible by i
        for j in range(1, n + 1):
            if j * i <= n:
                div[i * j] += 1
            else:
                break

    # Print the divisors
    return div

    # Driver Code


if __name__ == "__main__":
    n = int(input())
    print(sum(findDivisors(n-1)))

# This code is contributed by
# Vivek Kumar Singh

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    res = 0
    for i in range(1, N+1):
        res += N // i
        if N % i == 0:
            res -= 1
    print(res)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
'''
A*B<=N-1となるAとBの組み合わせが何通りあるかを調べること
この考えを導きだせるかが、この問題を解くカギとなる
Cの最小値1を右辺に移項してN-1となっている
不等式となっている点がポイント
Cの最小値1としておけばAとBの組み合わせを全部考えることができる
次に、AとBどちらでも良いが、あるA（もしくはB）が1つの値を決めたときに、
それに対応するB（もしくはA）が何通りあるかを計算して、A（もしくはB）の値をn-1まで
計算して足してあげれば答えとなる
とてもシンプルなコードだけどこれでACとなるはず
'''

for i in range(1,n):
    #print(i, (n-1)//i)
    ans += (n-1)//i
print(ans)

Submission status: Accepted

Solution code:
def slove():
    ans = 0
    for a in range(1,N):
        for b in range(1,N):
            c = N-a*b
            if c<=0: #a,b,cは>0なのでcが負になるときは組み合わせ除外
                break
            ans +=1
    return ans
N = int(input())
ans = slove()
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for a in range(1, n):
    ans += (n - 1) // a
print(ans)

Submission status: Accepted

Solution code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np
import collections as col

N = int(input())

ans = 0

for i in range(1,N):
    if N%i != 0:
        ans += N//i
    else:
        ans += N//i -1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
 
ans = 0
for i in range(1,n):
  ans += (n-1)//i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(1,n):
    s = (n-1)//i
    if  0< s < n:
        ans += s
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
x=0
for i in range(n):
    if i==0:
        continue
    elif n//i==n/i:
        x+=(n//i)-1
    else:
        x+=n//i
     
print(x)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    count = 0
    for a in range(N) :
        a += 1
        for b in range(N):
            b += 1
            c = N - a * b
            if c <= 0 :
                break
            else :
                count += 1

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
ans=0
for i in range(1,n):
    if n%i==0:
        ans+=(n//i)-1
    else:
        ans+=(n//i)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
for a in range(1,n):
    for b in range(1,n):
        if a*b <= n-1:
            cnt+=1
        else: break
print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
ans = 0
for i in range(1, n):
    ans += (n-1) // i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n):
    if n%i==0:
        ans += n//i
        ans -= 1
    else:
        ans += n//i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for a in range(1, N):
    ans += (N-1)//a

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0

for a in range(1,N):
    ans += N // a
    if N%a == 0:
        ans -= 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input()) - 1 # n=n-1
c, x = 0, 1
while x*x <= n:
    c += (n//x - x)*2 + 1
    x += 1
print(c)

Submission status: Accepted

Solution code:
n = int(input()) - 1 # n=n-1
print(sum([(n//x - x)*2 + 1 for x in range(1, int(n**0.5) + 1)]))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n):
	ans += n//i
	if n%i == 0:
		ans -= 1
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()

ans = 0
for a in range(1, N):
	ans += (N-1)//a

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
for i in range(1, n):
    a = (n-1)//i
    cnt += a

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
count=0
for i in range(1000010):
  if i==0:
    continue
  for j in range(1000010):
    if j==0:
      continue
    elif i*j<n:
      count+=1
    else:
      break
print(int(count))

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

import sys

def main():
    n = int(input())
    ans=0
    b=0

    for a in range(1,n):
        #A*B+C=n → A <= n-c//b
        #cは1<=c<=nなのでbで可変
        b=(n-1)//a
        ans+=b
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding:utf-8
n = int(input())
ans = 0

for a in range(1, n):
    ans += (n - 1) // a

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
r = 0
for A in range(1, N+1):
	for B in range(1, N+1):
		if A * B >= N: break
		r += 1
print(r)

Submission status: Accepted

Solution code:
n = int(input())

count = 0
for i in range(1,n):
    count += (n - 1)//i
     
print(count)

Submission status: Accepted

Solution code:

def main():

	N = int(input())
	ans = 0
	for a in range(1, N):
		for b in range(1, N):
			c = N - a * b
			if c > 0:
				ans += 1
			else:
				break

	print(ans)

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
for a in range(1, N):
    # print(f'{a=}, {N // a}')
    cnt += (N - 1) // a

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for a in range(1,N):
    ans += (N-1)//a
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = 0
    for a in range(1, n):
        for b in range(1, n):
            c = n - a * b
            if c <= 0:
                break
            ans += 1
    return ans


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:

n=int(input())
#d = [list(map(int,input().split())) for _ in range(s)]

def p(val):
    print(val)

count = 0

#cは1以上で、問題文からN-1 a*b <=N-1のものをもとめる
#aを1からふやしてく、cはaとbが決まれば自動歴に決まるので、
for i in range(1,n):
    count +=(n-1)//i

    

        
p(count)

Submission status: Accepted

Solution code:
N=int(input())
Ans=0

for i in range(1,N):
  Ans+=(N-1)//i

print(Ans)

Submission status: Accepted

Solution code:
n = int(input())
import math
ans = 0
for i in range(1, n+1):
    ans += (n-1)//i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for i in range(1,n):
  count += (n-1) // i
print(count)

Submission status: Accepted

Solution code:
from functools import lru_cache
N = int(input())
# A * B <= N - 1はいくつありますか？
count = 0
# A ∈ {1, 2, ..., N-1}
for A in range(1, N):
    # B <= (N - 1) // A
    count += (N - 1) // A
print(count)

Submission status: Accepted

Solution code:
N = int(input())
 
ans = 0
for a in range(1, N ):
   for b in range(1, N // a + 1):
      if a * b < N:
         ans += 1
 
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
N=int(input())

### 関数＆defaultdict版
def factorize(M):
  res=defaultdict(int)
  #for i in range(2,int(M**0.5)+1):
  for i in prime_list:  
    if M==1:
      break
    while M%i==0:
      M//=i
      res[i]+=1  
  if M!=1:
    res[M]=1
  return res

# n"未満"の素数のリストを得る
def prime_sieve(n):
  prime_list=[True]*n
  prime_list[0]=False
  prime_list[1]=False
  for i in range(2,int(n**0.5)+1):
    if not prime_list[i]:
      continue
    else:
      for j in range(i**2,n,i):
        prime_list[j]=False
  return [i for i in range(n) if prime_list[i]]

prime_list=prime_sieve(int(N**0.5)+1)
answer=0
for i in range(1,N):
  facts=factorize(i)
  
  num_div=1
  for k,v in facts.items():
    num_div*=v+1
  answer+=num_div
  
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
for i in range(1,n):
    cnt += (n-1)//i
print(cnt)

Submission status: Accepted

Solution code:
try:
  n = int(input())
  result = 0
  for i in range(1, n):
    result += (n - 1) // i
  print(result)

except Exception:
  pass

Submission status: Accepted

Solution code:
import math
n = int(input())
ans = 0
for i in range(1, n):
  ans += math.ceil(n / i) - 1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
count = 0
for a in range(1,N):
	count += (N-1)//a 
print(count)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1,n):
    ans += (n-1)//i

print(ans)