View Code of Problem 3920

#include <stdio.h>

int main() {
	int a[10] = { 0,45,40,45,40,25,40,45,40,45 };
	int q;
	long long int n, m;
	scanf("%d", &q);
	while (q--) {
		scanf("%lld %lld", &n, &m);
		long long int x = n / m;
		long long int res = a[m % 10] * (x / 10);
		int temp = x % 10;
		int y = m % 10;
		for (int i = 1;i <= temp;i++) {
			res += (y*i) % 10;
		}
		printf("%lld\n", res);
	}
}

Double click to view unformatted code.


Back to problem 3920