codeforces 931A - Friends Meeting 模拟
2018-03-06 18:13
316 查看
http://codeforces.com/contest/931/problem/A
数轴上有两人分别在点a,b,人每走一下增加一点疲劳值,且递增,如左1,左1,左1,疲劳值为1+2+3=6。两个人都能走,现希望两人碰面,且求最小疲劳值之和。
取两人中点,直接计算。
数轴上有两人分别在点a,b,人每走一下增加一点疲劳值,且递增,如左1,左1,左1,疲劳值为1+2+3=6。两个人都能走,现希望两人碰面,且求最小疲劳值之和。
取两人中点,直接计算。
#include <bits/stdc++.h> using namespace std; int n,a,b; int main(){ cin >> a >> b; if (a>b) swap(a,b); int mid=(a+b)/2; a=mid-a; b=b-mid; cout << a*(a+1)/2+b*(b+1)/2 << endl; }
相关文章推荐
- Codeforces 716B Complete the Word【模拟】 (Codeforces Round #372 (Div. 2))
- Codeforces 691B. s-palindrome(模拟)
- Codeforces 879 B Table Tennis(模拟)
- Codeforces 174B【模拟构造】
- Codeforces 653C Bear and Up-Down 【模拟】
- CodeForces - 931B World Cup(模拟)
- Codeforces - 362 (Div. 2)B - Barnicle(模拟)
- CodeForces - 366B Dima and To-do List (模拟) 水
- 【模拟】【codeforces】599B Spongebob and Joke
- Codeforces 472B - Design Tutorial: Learn from Life(模拟)
- Codeforces 381A Sereja and Dima(模拟)
- CodeForces 724|模拟|贪心|扩展欧几里得|
- Codeforces 545D Queue【贪心+模拟】
- Codeforces 439C Devu and Partitioning of the Array(模拟)
- codeforces--Spreadsheets(模拟)
- Codeforces-691C Exponential notation(模拟)
- CodeForces - 628C Bear and String Distance (模拟)
- CodeForces 670E Correct Bracket Sequence Editor(list和迭代器函数模拟)
- CodeForces 404 Marathon ( 浮点数取模 -- 模拟 )
- [codeforces] C. Epidemic in Monstropolis 复杂模拟