题解:P16336 「ALFR Round 10」Another Add Problem
DaDaLin2014 · · 题解
题目传送门
思路
要想让余数最小,则尽量让
所以分以下几种情况讨论:
AC code
#include<iostream>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n,m,k;
cin>>n>>m>>k;
if(m==0){
cout<<n<<endl;
}else if(m<=k-n%k){
cout<<n%k<<endl;
}else{
cout<<0<<endl;
}
}
return 0;//完结撒花!!!
}