-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC_Book_Reading.cpp
More file actions
47 lines (34 loc) · 754 Bytes
/
C_Book_Reading.cpp
File metadata and controls
47 lines (34 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
long long n, m;
cin >> n >> m;
long long k = n / m;
vector<int> cycle;
for (int i = 1; i <= 10; i++)
{
cycle.push_back((i * m) % 10);
}
long long cycleSum = 0;
for (int x : cycle)
cycleSum += x;
long long fullCycle = k / 10;
long long rem = k % 10;
long long ans = fullCycle * cycleSum;
for (int i = 0; i < rem; i++)
{
ans += cycle[i];
}
cout << ans << endl;
}
}