1 solutions

  • 0
    @ 2025-12-3 8:44:14

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int work(int x,int y)
    {
    	int c=x%y,ans=0;	
    	if(c==0) ans=0;
    	else   ans=(x/y+1)*y-x;
    	return ans;
    }
    int n,a,b;
    int main()
    {
    //	freopen("1016.in","r",stdin);
    //	freopen("1016.out","w",stdout);	
    	cin>>n>>a>>b;
    	int a1=work(n,a),b1=work(n,b);
    	cout<<min(a1,b1);
    	return 0;
    }
    
    • 1

    Information

    ID
    779
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    2
    Accepted
    1
    Uploaded By