好吧,其实我拿到这个题的时候,首先想到了bfs,写完之后,开开森森的去交代码,却在第二个数据就TEL,然后优化半天,还是不行。
最终,我盯着1,2,5发呆半天,wc,然后直接贪心
#include<iostream> using namespace std; int main() { int T; cin>>T; while(T--) { int a,b; cin>>a>>b; int x = abs(a - b); int ans = x / 5; x %= 5; ans += x / 2; x %= 2; ans += x; cout<<ans<<endl; } return 0; }