Slow Solution

Problem Code:
SLOWSOLN

Contest Code:Practice
Submission byrashmi1729
Submitted: 6 days ago

Status:
Correct Answer

Language : C
(NOTE : Try a few times yourself before moving to the solution)


#include <stdio.h>

int main(void) {
	int t;
	scanf("%d\n",&t);
	
	while(t--)
	{
	    int tc, n, total;
	    scanf("%d %d %d\n",&tc,&n,&total);
	    
	    int counter = 0;
	    long long int prod = 0;
	    
	    
	    while(total > 0 && counter < tc)
	    {
	        if(total >= n)
	        prod += n*n;
	        else
	        prod += total * total;
	        
	        counter++;
	        total -= n;
	        
	       // printf("%d %d %d\n", prod,counter,total);
	        
	    }
	    
	    printf("%lld\n",prod);
	}
	return 0;
}




No comments:

Post a Comment