codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

478B.md (1636B)


      1 Source: https://codeforces.com/problemset/problem/478/B
      2 
      3 B. Random Teams
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 *n* participants of the competition were split into *m* teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.
     22 
     23 Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could have formed by the end of the competition.
     24 
     25 Input
     26 
     27 The only line of input contains two integers *n* and *m*, separated by a single space (1 ≤ *m* ≤ *n* ≤ 109) — the number of participants and the number of teams respectively.
     28 
     29 Output
     30 
     31 The only line of the output should contain two integers *k**min* and *k**max* — the minimum possible number of pairs of friends and the maximum possible number of pairs of friends respectively.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 5 1
     39 ```
     40 
     41 Output
     42 
     43 ```
     44 10 10
     45 ```
     46 
     47 Input
     48 
     49 ```
     50 3 2
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 1 1
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 6 3
     63 ```
     64 
     65 Output
     66 
     67 ```
     68 3 6
     69 ```
     70 
     71 Note
     72 
     73 In the first sample all the participants get into one team, so there will be exactly ten pairs of friends.
     74 
     75 In the second sample at any possible arrangement one team will always have two participants and the other team will always have one participant. Thus, the number of pairs of friends will always be equal to one.
     76 
     77 In the third sample minimum number of newly formed friendships can be achieved if participants were split on teams consisting of 2 people, maximum number can be achieved if participants were split on teams of 1, 1 and 4 people.