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

Solution in C (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n;
	int *a;
	int is_prime[1001];
	int *primes;
	scanf("%d", &n);
	a = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		a[i] = 1;
	}
	for(int i=0; i<1001; i++){
		is_prime[i] = 1;
	}
	for(int j=0; j<1001; j++){
		int k;
		if(j == 0 || j == 1){
			is_prime[j] = 0;
		}
		else if(is_prime[j]*is_prime[j]<=1000){
			if(is_prime[j] == 1){
				k = j*2;
				while(k<1001){
					is_prime[k] = 0;
					k += j;
				}
			}
		}
	}
	int primes_c = 0;
	for(int i=0; i<1001; i++){
		if(is_prime[i] == 1){
			primes_c++;
		}
	}
	int c = 0;
	primes = (int *)malloc(sizeof(int) * primes_c);
	for(int i=0; i<1001; i++){
		if(is_prime[i] == 1){
			primes[c] = i;
			c++;
		}
	}

	for(int i=1; i<n; i++){
		for(int j=0; j<primes_c; j++){
			int p = primes[j];
			int x = 0;
			int ii = i;
			while(ii%p == 0){
				ii /= p;
				x++;
			}
			a[i] *= x+1;
		}
	}
	long sum = 0;
	for(int i=1; i<n; i++){
		sum += a[i];
	}
	printf("%ld\n", sum);
	return 0;
}