A. Changing Volume
【题目类型】简单数学
【题目链接】A题链接
【题目大意】给你数字 n 经过 k 次(−5,−2,−1,+1,+2,+5) 操作得到 m ,问最小k是多少?
【解题思路】实际上只需要求解出差值,对差值进行贪心的操作,先看能进行几次5操作,再看能进行几次2操作,再看能进行几次1操作即可
【代码】
/** * This code has been written by YueGuang, feel free to ask me question. Blog: http://www.yx.telstudy.xyz * created: */
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;
using namespace std;
int main(){
int q; scanf("%d", &q);
while(q--){
int a, b;scanf("%d%d", &a, &b);
int cnt = 0, tmp = abs(b - a);
cnt += tmp/5;
cnt += (tmp%5)/2;
cnt += (tmp%5%2)/1;
cout << cnt <<'\n';
}
}