fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #define ll long long
  4.  
  5. int solve(int n, ll k){
  6. int sum = 0;
  7. for(int i = 1; i <= n; i ++){
  8. sum += i % k;
  9. }
  10. return sum;
  11. }
  12.  
  13. int main(){
  14. int t;
  15. scanf("%d", &t);
  16. while(t--){
  17. int n;
  18. long long k;
  19. scanf("%d%lld", &n, &k);
  20. printf("%d\n", solve(n, k));
  21. }
  22. }
Success #stdin #stdout 0.01s 5412KB
stdin
2
10 55
1 11
stdout
55
1