Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main()
- {
- int test;
- cin >> test;
- for (int i = 1; i <= test;i++)
- {
- int n, k;
- cin >> n >> k;
- if (n%k == 0)
- cout << (((n / k)*(n - n / k))*k) / 2 << endl;
- else
- cout << ((((n / k)*(n - n / k))*(k - n%k)) + (n / k + 1)*(n - (n / k + 1))*(n%k)) / 2 << endl;
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment