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: Accepted

Solution code:
# cook your dish here
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(s, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if s[mid] == val:return mid
        elif s[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,s):
    for i in range(1,n):s[i]+=s[i-1]
    return s;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;

# coding start heres
MAX = ii1()
factor = [0]*(MAX + 1);
def primefactor():
    factor[1] = 1;
    for i in range(2,MAX):
        factor[i] = i;
    for i in range(4,MAX,2):
        factor[i] = 2;
    i = 3;
    while(i * i < MAX):
        if (factor[i] == i):
            j = i * i;
            while(j < MAX):
                if (factor[j] == j):
                    factor[j] = i;
                j += i;
        i+=1;
def fun(n):
    if (n == 1):
        return 1;
    ans = 1;
    dup = factor[n];
    c = 1;
    j = int(n / factor[n]);
    while (j > 1):
        if (factor[j] == dup):
            c += 1;
        else:
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        j = int(j / factor[j]);
    ans = ans * (c + 1);
    return ans;

if __name__ == "__main__":
    primefactor()
    sum=0
    for i in range(1,MAX):
        a=fun(i)
        sum+=a
    print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

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

print(s)

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

tmp = num_divisors_table(n-1)
print(sum(tmp))

Submission status: Accepted

Solution code:
N = int(input())

count = 0

for i in range(N - 1):
    A = i + 1
    B = N / A

    if B == int(B):
        count += B-1
    else:
        count += int(B)

print(int(count))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
import collections

def I(): 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 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 main():
    n = I()
    ans = 0
    for c in range(1, n):
        t = list(collections.Counter(prime_factorize(n-c)).values())
        s = 1
        for key in t:
            s *= key+1
        ans += s
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
i=1
while i<n:
    cnt+=(n-1)//i
    i+=1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

count = [1]*(N+1)

ans = count[1]
for i in range(2, N):
    k = i
    while k < N:
        count[k] += 1
        k += i

    ans += count[i]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

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+1):
    b=n//a
    c=n-a*b

    if c==0:
        cnt+=b-1
    else:
        cnt+=b


print(cnt)

Submission status: Accepted

Solution code:
import math
N=int(input())
rtN=int(math.sqrt(N))
if rtN**2!=N:
    rtN+=1
    
ans=0
for i in range(1,rtN):
    tmp=N//i if N%i!=0 else N//i-1
    ans+=2*(tmp-i)+1
print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())

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

Submission status: Accepted

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

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:
            break
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
# abc179_c.py
import math
N = int(input())
cnt = 0
for i in range(1,N+1):
    if i*(N//i)==N:
        # print(i,N//i-1)
        cnt += N//i-1
    else:
        cnt += N//i
        # print(i,N//i)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
 
count = 0
for a in range(1, N):
    ans, mod = divmod(N, a)
    if mod == 0:
        count += ans - 1
    else:
        count += ans
 
print(count)

Submission status: Accepted

Solution code:
N = int(input())
def ans(N):
  count = 0
  for i in range(1,N):
    for j in range(i,int(N/i)+1):
      if N-i*j>=1 and i!=j:
        count += 2
      elif N-i*j>=1 and i==j:
        count += 1
  return count

print(ans(N))

Submission status: Accepted

Solution code:

def main():
  n = int(input())
  cnt = 0
  same = 0

  for a in range(1, n):
    for b in range(a, n):
      if a * b >= n:
        break

      cnt += 1
      if a == b:
        same += 1

  print((cnt - same) * 2 + same)



main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

half_n = n // 2

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

res = n - half_n - 1
ans += res

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=int(1)
ans=int(0)
while a < n:
  ans = ans + (n-1) // a
  a = a + 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
# def print_factors(x):
#     print("The factors of",x,"are:")
#     arr = []
#     for i in range(1, x + 1):
#         if x % i == 0:
#             arr.append(i)
#     return len(arr)
# ans = 1
# Python3 program to count  
# number of factors 
# of an array of integers 
MAX = 1000001; 
  
# array to store 
# prime factors 
factor = [0]*(MAX + 1); 
  
# function to generate all  
# prime factors of numbers 
# from 1 to 10^6 
def generatePrimeFactors(): 
    factor[1] = 1; 
  
    # Initializes all the  
    # positions with their value. 
    for i in range(2,MAX): 
        factor[i] = i; 
  
    # Initializes all  
    # multiples of 2 with 2 
    for i in range(4,MAX,2): 
        factor[i] = 2; 
  
    # A modified version of  
    # Sieve of Eratosthenes 
    # to store the smallest  
    # prime factor that divides 
    # every number. 
    i = 3; 
    while(i * i < MAX): 
        # check if it has 
        # no prime factor. 
        if (factor[i] == i): 
            # Initializes of j  
            # starting from i*i 
            j = i * i; 
            while(j < MAX):  
                # if it has no prime factor  
                # before, then stores the  
                # smallest prime divisor 
                if (factor[j] == j): 
                    factor[j] = i; 
                j += i; 
        i+=1; 
  
# function to calculate 
# number of factors 
def calculateNoOFactors(n): 
    if (n == 1): 
        return 1; 
    ans = 1; 
  
    # stores the smallest  
    # prime number that 
    # divides n 
    dup = factor[n]; 
  
    # stores the count of  
    # number of times a  
    # prime number divides n. 
    c = 1; 
  
    # reduces to the next  
    # number after prime 
    # factorization of n 
    j = int(n / factor[n]); 
  
    # false when prime  
    # factorization is done 
    while (j > 1): 
        # if the same prime  
        # number is dividing  
        # n, then we increase 
        # the count 
        if (factor[j] == dup): 
            c += 1; 
  
        # if its a new prime factor 
        # that is factorizing n,  
        # then we again set c=1 and  
        # change dup to the new prime  
        # factor, and apply the formula  
        # explained above.  
        else: 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
  
        # prime factorizes 
        # a number 
        j = int(j / factor[j]); 
  
    # for the last 
    # prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
# Driver Code 
  

      
# generate prime factors 
# of number upto 10^6 
generatePrimeFactors() 
ans = 1
# for i in range (0,1): 
#     print(calculateNoOFactors(n)) 

for i in range(2, n):
    cur = calculateNoOFactors(i)
    ans += cur
    #print( str(i) + " is " + str(cur) )
print(ans)

Submission status: Accepted

Solution code:
def main():
    num = int(input())

    A = 1
    count = 0
    flg = False

    while(True):
        B = 1
        while(True):
            cal = A * B
            if cal < num:
                count += 1
                B += 1
            else:
                if B == 1:
                    flg = True
                break
        if flg:
            break
        A += 1

    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = n**(0.5)
if n%a==0:
    a = a-1
else:
    pass
a = int(a)
#print(a)
ans = 0
for i in range(1,a+1):
    #print(i)
    b = n//i
    if n%b==0:
        b=b-1
    else:
        pass
    #print(b)
    ans += (b-i)*2+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 - 1):
    ans += N // i
    if N % i == 0:
        ans -= 1

print(ans + 1)

Submission status: Accepted

Solution code:
def cnt(A, N):
    t = N // A
    if N % A == 0:
        return t - 1
    else:
        return t

N = int(input())
s = 0
for i in range(1, N):
    s += cnt(i, N)

print(s)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

ans=0

for i in range(1,N):
    a = N//i
    #print(i,a)
    if a!=N/i:
        ans+=a
    else:ans+=a-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())
memo = [1]*(N)
memo[0] = 0
ans = 0
for i in range(2,N):
    tmp = i
    while tmp < N:
        memo[tmp] += 1
        tmp += i
print(sum(memo))

Submission status: Accepted

Solution code:
N = int(input())
counter = 0
for A in range(1,N):
  for B in range(1,N//A+1):
    if 0 < A*B < N:
        counter += 1
print(counter)

Submission status: Accepted

Solution code:
def resolve():
    #n=int(input())
    #a,b=map(int,input().split())
    #x=list(map(int,input().split()))
    #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]
    n=int(input())
    ans=0
    for a in range(1,n):
      if n-a*a<=0:
        break
      else:
        ans+=1
    for a in range(1,n-1):
      for b in range(a+1,n):
        if n-a*b<=0:
          break
        else:
          ans+=2
    print(ans)

if __name__ == '__main__':
    resolve()

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:
            break
        else:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import math
import sys
import os

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

def divisor_count(n):
    divisors = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors += 1
            if i != n // i:
                divisors += 1  
    return divisors    

N = I()
ans = 0

# for i in range(1,N):
#     ans += divisor_count(i)

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):
    ue=math.floor((n-1)/i)
    ans+=ue

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for A in range(1, 1000):
    for B in range(A, 1000000):
        C = N - A * B
        if C <= 0:
            break
        # print(A, B, C)
        if A != B:
            ans += 2
        else:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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]


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ans = 0
    for a in range(1, N):
        if N % a == 0:
            b_num = N // a - 1
        else:
            b_num = N // a

        ans += b_num

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

n = int(input())
divisors = num_divisors_table(n-1)

print(sum(divisors))

Submission status: Accepted

Solution code:
n = int(input())

count = 0
for a in range(1,n):
  for b in range(1,n):
    if a*b<n:
      count += 1
    else:
      break

print(count)

Submission status: Accepted

Solution code:
n = 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]

yakusu = make_divisors(n)
l_yakusu = len(yakusu)
count = 0
yakusu_idx = 0
#aの通り数でfor
for a in range(1,n):
    b = n//a
    if b < a:
        break
    if yakusu_idx < l_yakusu and a == yakusu[yakusu_idx]:
        tmp = (b-a)*2
        if tmp>0:
            count += tmp - 1
        yakusu_idx += 1
    else:
        tmp = (b-a+1)*2
        if tmp>0:
            count += tmp -1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
y = n
res = 0
for x in range(1, n+1):
    while x*y >= n:
        y -= 1
    res += y
print(res)

Submission status: Accepted

Solution code:
import math
n=int(input())


maxa=math.floor((n-1)**0.5)
#print(maxa)

PossibleB=0

#a>=b を仮定
for a in range(1,maxa+1):
  #print(a)
  #print(math.floor((n-1)/a)-(a-1))
  PossibleB += math.floor((n-1)/a)-(a-1)

#a==b　の重複は削除
print(2*PossibleB-maxa)

Submission status: Accepted

Solution code:
import sys
import math
n = int(sys.stdin.readline().rstrip("\n"))
n_2 = math.ceil(math.sqrt(n))
ans = 0
for a in range(1,n_2):
    q, mod = divmod(n, a)
    if mod == 0:
        bmax = q
    else:
        bmax = q + 1
    for b in range(a,bmax):
        if a == b:
            ans += 1
        else:
            ans += 2
print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans_onaji = 0
    ans_dif = 0
    for i in range(1, n):
        for j in range(i, n):
            if i == j and i*j <= n-1:
                ans_onaji += 1
            elif i != j and i*j <= n-1:
                ans_dif += 1
            elif i*j > n-1:
                break
    print(ans_dif * 2 + ans_onaji)






if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())-1
s=0

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

print(s)

Submission status: Accepted

Solution code:
import math

N=int(input())
z = 0
for i in range(1,N):
    a = math.floor(N / i)
    z += a
    if N % i == 0:
        z -= 1
print(z)

Submission status: Accepted

Solution code:
def ndt(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

N=int(input())
print(sum(ndt(N-1)))

Submission status: Accepted

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

Submission status: Accepted

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

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


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

# for c in range(1, n):
#     tar = n-c
#     for a in range(1, int(tar**0.5)+1):
#         if tar % a == 0:
#             b = tar // a
#             if b > 0 and a != b:
#                 cnt += 2
#             elif b > 0:
#                 cnt += 1
#
# print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

main()

Submission status: Accepted

Solution code:
import collections

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 main():
    n = int(input())
    res = 0
    for c in range(1,n):
        ab = n - c
        col = collections.Counter(prime_factorize(ab))
        r = 1
        for count in col.values():
            r *= count+1
        res += r
    print(res)


if __name__ == "__main__":
    main()

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:
#ABC179 c
n = int(input())
count = 0
for i in range(1, n):
  a = n // i
  b = n % i
  if b==0:
    count += a-1
  else:
    count += a
print(count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    cnt = 0
    for i in range(1,N):
        a = N//i
        if N%i == 0:
            cnt += a-1
        else:
            cnt += a
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
count=0
for i in range(1,n):
    x=n/i
    if x.is_integer():
        count+=x-1
    else:
        count+=int(x)

print(int(count))

Submission status: Accepted

Solution code:
n = int(input())

count=0

for i in range(1,n):
  for j in range(1,n):
    if i * j < n:
      count += 1
    else:break

print(count)

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0
for a in range(1, n):
    for b in range(1, n):
        x = a * b
        if x >= n:
            break
        cnt += 1

print(cnt)

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:
N=int(input())
ans=0
for i in range(1,N):
   ans+=(N-1)//i
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math


def main():
    N = int(sys.stdin.readline().rstrip())

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

    print(cnt)


main()

Submission status: Accepted

Solution code:
n = int(input())

cnt=0
for i in range(1,n):
    for j in range(1,n):
        if i*j >= n:
            break
        cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
def cp(n):
    lp=[0]*(n+1)
    pr=[]
    for i in range(2,n+1):
        if lp[i]==0:
            lp[i]=i
            pr.append(i)
        for p in pr:
            if p*i>n or p>lp[i]:
                break
            lp[p*i]=p
    return lp

def ra(a): #圧縮された要素を非保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll


n=int(input())
ans=0
cppp=cp(n)
for i in range(1,n):
    c=n-i
    prime=[]
    while c>1:
        prime.append(cppp[c])
        c//=cppp[c]
    l=ra(prime)
    k=1
    for j in l:
        k*=j+1
    ans+=k
print(ans-1)

Submission status: Accepted

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

for i in range(1, N):
    b = N//i
    if i*b == N:
        b -= 1
    # print(i, b)
    ans += b
print(ans)

Submission status: Accepted

Solution code:
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
    
N = int(input())
    
print(sum(num_divisors_table(N)[:-1]))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    cnt = 0
    for i in range(N - 1):
        A = i + 1
        B = 1
        while A * B < N:
            cnt += 1
            B += 1

    print(cnt)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
LI = lambda: list(map(int, input().split()))

N = int(input())


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

Solution code:
def main():
	cnt = 0
	N = int(input())
	for a in range(1,N):
		for b in range(1,N):
			if a*b >= N:
				break
			else:
				cnt += 1
	print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1,N):
  n = i
  while n < N:
    ans += 1
    n += i
print(ans)

Submission status: Accepted

Solution code:
#coding:utf-8
import math

N = int(input())

ans = 0

for i in range(1,N+1):
    b = math.ceil(N / i) - 1
    ans += b

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
n_sqrt = math.sqrt(n)

l = [2] * (n - 1)
l[0] = 1

for i in range(2, math.floor(n_sqrt) + 1):
  k = (n - 1) // i
  for j in range(2, k+1):
    l[j * i - 1] += 2 if j > n_sqrt else 1
    
print(sum(l))

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    n = int(input())

    if n == 2:
        print(1)
    else:
        count = 1
        n2=n-1
        for i in range(1,n2):
            count+=n2//i
        print(count)

Submission status: Accepted

Solution code:
N=int(input())
n=N-1
ans=0
for a in range(1,N):
  B=n//a
  ans+=B
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:
N = int(input())
ans = 0
a = 1
while(a < N):
    ans += (N-1)//a # bmax
    a += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
ans = 0
for A in range(1, N):
  for B in range(1, N):
    if A * B > N-1:
      break
    else:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
from collections import Counter


class SmallestPrimeFactors:
    def __init__(self, n):
        self.spf = list(range(n + 1))
        self.spf[0] = -1
        self.spf[1] = -1
        for i in range(2, int(n ** 0.5) + 1):
            if self.spf[i] == i:
                for j in range(i * i, n + 1, i):
                    if self.spf[j] == j:
                        self.spf[j] = i

    def is_prime(self, x):
        return self.spf[x] == x

    def __traverse(self, x):
        if self.spf[x] == x:
            return [x]
        nxt = x // self.spf[x]
        return self.__traverse(nxt) + [self.spf[x]]

    def factor(self, x):
        if x < 2:
            return []
        return self.__traverse(x)


spf = SmallestPrimeFactors(1_000_000)
N = int(input())
ans = 0
for C in range(1, N):
    fac = Counter(spf.factor(N - C))
    tmp = 1
    for v in fac.values():
        tmp *= v + 1
    ans += tmp
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
count = 0
for a in range(1, n):
    if n % a == 0:
        count += n // a - 1
    else:
        count += n // a
print(count)

Submission status: Accepted

Solution code:
n = int(input())
a = 1
cnt = 0
while n > a:
    cnt += (n-1) // a
    a += 1

print(cnt)

Submission status: Accepted

Solution code:
from math import sqrt as r
from math import floor

N = int(input())
n = N - 1
ans = 0

for A in range(1, N):
    B = n // A
    ans += B

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
L=[*range(n)]
S=[1]*n
for i in range(2,n):
  for j in range(i,n,i):
    a=0
    while L[j]%i<1:
      L[j]//=i
      a+=1
    S[j]*=a+1
print(sum(S)-1)

Submission status: Accepted

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

print(cnt)