Problem Statement
Hint: If the input is 15 squares
rectangles are-
1x1 1x2 1x3 ...................................1x15
2x2 2x3 ............................2x7
3x3 ....................3x5
#include<stdio.h>
int main()
{
int n,c=0,i,j;
scanf("%d",&n);
for(i=1;i*i<= n;i++)
{
c+= (n/i)-i+1;
}
printf("%d\n",c);
}
* If there's any query or mistake, let me know.
Hint: If the input is 15 squares
rectangles are-
1x1 1x2 1x3 ...................................1x15
2x2 2x3 ............................2x7
3x3 ....................3x5
- can't make 3x2 cause 3x2 and 2x3 are same.
- can't make 2x8 cause that requires 16 squares.
- can't make 4x4 cause that also requires 16 square.
#include<stdio.h>
int main()
{
int n,c=0,i,j;
scanf("%d",&n);
for(i=1;i*i<= n;i++)
{
c+= (n/i)-i+1;
}
printf("%d\n",c);
}
* If there's any query or mistake, let me know.
Comments
Post a Comment