# tomato problem

, ,

Consider the entire town of Chefville to be consisting of cells in a rectangular grid of positive coordinates.

Chef own all cells (x,y)
that satisfy x∗y≤N

As an example if N=4

, Chef owns the following cells:

(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(3,1),(4,1)

Chef can only grow tomatoes in rectangular patches consisting only of cells which belong to him. Also, if he uses a cell, he must use it entirely. He cannot use only a portion of it.

Help Chef find the number of unique patches of rectangular land that he can grow tomatoes in! Since this number can be very large, output it modulo 1000000007

.
Input:

``````The first line of the input contains T
``````

, the number of test cases.
The next T
lines of input contains one integer N

``````.
``````

Output:

For each testcase, output the number of ways modulo 1000000007

.
can anyone help me writing this code in basic c language

1 Like

#include <stdio.h>

#include <math.h>

#define ll long long int

#define M 1000000007

int main()

{

``````int t;

scanf("%d", &t);

while (t--)

{

ll n, i, ans = 0, x;

scanf("%lld", &n);

x = (ll)floor(sqrt(n));

for (i = 1; i <= x; i++)

{

ll val = i;

val = ((val % M) * ((i + (ll)floor(n / i)) % M)) % M;

val = ((val % M) * ((1 + (ll)floor(n / i) - i) % M)) % M;

ans = (ans % M + val % M) % M;

}

ans = (ans % M - ((x * (x + 1) * (2 * x + 1)) / 6) % M + M) % M;

printf("%lld\n", ans);

}

return 0;
``````

}