View Code of Problem 3920

#include <stdio.h>

int main()
{
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++)
	{
		int col[20]={0};
		long long n,m,sum=0;
		scanf("%lld%lld",&n,&m);
		long long temp;
		temp=n%m;
		n-=temp;
		temp=n/m;
		int num=m%10;
		long long sum10=0;
		for(int j=1;j<=10;j++)
		{
			col[j]=num*j%10;
			sum10+=col[j];
		}
		if(temp/10>=1)
		{
			sum+=sum10*(temp/10);
		}
		temp%=10;
		for(long long j=1;j<=temp;j++)
		{
			
			sum+=col[j];		
		}
		printf("%lld\n",sum);	
	}	
} 

Double click to view unformatted code.


Back to problem 3920