Pagini recente » Cod sursa (job #2192848) | Cod sursa (job #1353108) | Cod sursa (job #2702259) | Cod sursa (job #2621063) | Cod sursa (job #2398249)
#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]++;
}
}
return 0;
}