View Code of Problem 3920

#include <bits/stdc++.h>
using namespace std;

int main() {
	int q;
	cin >> q;
	while (q--) {
		long long n, m;
		long long sum = 0;
		cin >> n >> m;
		for (long long i = 1; i * m <= n; ++i) {
			sum += i * m % 10;
		}
		cout << sum << endl;
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 3920