题目链接
题意给n和k,做任意次操作,每次操作可以把n变为n-k的绝对值,求能得到的最小的n思路
-
对n%k,直接得出n减若干个k能得到的最小值a
-
a与a-k的绝对值 求两者最小值
-
long long
#include#define endl 'n' #define int long long using namespace std; const int N = 2e5+10; typedef long long ll; signed main() { ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); int n,k; cin>>n>>k; int a=n%k; int b=abs(n%k-k); cout< 总结 小学数学题


![AT4896 [ABC161C] Replacing Integer AT4896 [ABC161C] Replacing Integer](http://www.mshxw.com/aiimages/31/656036.png)
