Pagini recente » Cod sursa (job #2169917) | Cod sursa (job #2760675) | Cod sursa (job #1424612) | Cod sursa (job #2927592) | Cod sursa (job #2398253)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("next.in");
ofstream g("next.out");
unsigned long long x,d,i;
int a[1000005];
bool ok;
char ch;
int rest(long long d)
{
int t=0;
long long i=0;
for(i=a[0]; i>=1; i--)
{
t=t*10+a[i];
t=t%d;
}
return t;
}
int main()
{
while(f.get(ch))
{
if(ch=='\n')
break;
else
{
a[++a[0]]=ch-'0';
}
}
f>>d;
reverse(a+1,a+a[0]+1);
while(ok==false)
{
if(rest(d)==0)
{
for(i=a[0]; i>=1; i--)
g<<a[i];
g<<'\n';
break;
}
else
{
i=1;
while(a[i]==9)
{
a[i]=0;
i++;
}
a[i]++;
if(i>a[0])
a[0]=i;
}
}
return 0;
}