codeforces-scrape

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

931.md (1066B)


      1 Source: https://codeforces.com/blog/entry/58177
      2 
      3 ### [931A - Friends Meeting](/contest/931/problem/A "Codeforces Round 468 (Div. 2, based on Technocup 2018 Final Round)")
      4 
      5 At first understand the fact that friend should make their moves one be one and the friend who initially was left should move to the right and other friend should move to the left. Let *len* = |*a* - *b*|. Then the first friend will make *cntA* = *len* / 2 moves, and the second friend — *cntB* = *len* - *len* / 2 moves. So the answer is the sum of two arithmetic progressions *cntA*·(*cntA* + 1) / 2 and *cntB*·(*cntB* + 1) / 2.
      6 
      7 The given constrains allowed to calculate this sums in linear time — simply iterate from 1 to *cntA* for the first sum and from 1 to *cntB* to the second.
      8 
      9 Tutorial is loading...
     10 
     11 Tutorial is loading...
     12 
     13 Tutorial is loading...
     14 
     15 Tutorial is loading...
     16 
     17 Tutorial is loading...
     18 
     19 Tutorial is loading...
     20 
     21 Tutorial is loading...
     22 
     23 Thanks [GreenGrape](/profile/GreenGrape "Candidate Master GreenGrape") for translation!