Cod sursa(job #484815)
Utilizator | Data | 15 septembrie 2010 22:10:31 | |
---|---|---|---|
Problema | Next | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.32 kb |
#include<fstream>
using namespace std;
ifstream in("next.in");
ofstream out("next.out");
int main()
{
unsigned long long n,d,i;
in>>n>>d;
i=n;
if(n%d==0)
{
out<<n;
return 0;
}
if((i+1) %d==0)
{
out<<n;
return 0;
}
if(d%2==0 && i%2==1)
i++;
while(i%d!=0)
i+=2;
out<<i;
return 0;
}