Pagini recente » Cod sursa (job #888622) | Cod sursa (job #2538626) | Cod sursa (job #2234594) | listare_agm | Cod sursa (job #1039213)
#include <cstdio>
#include <cstring>
const int nmax= 1000000;
long long v[nmax+1];
char s[nmax+1];
int main( ) {
freopen( "next.in", "r", stdin );
freopen( "next.out", "w", stdout );
scanf("%s", &s);
int x= strlen(s)-1;
for ( int i= x; i>=0; --i ) {
v[x-i]= s[i]-'0';
}
long long d;
scanf( "%lld", &d );
long long t= 0;
for ( int i= x; i>=0; --i ) {
t= (t*10+v[i])%d;
}
t= (d-t)%d;
for ( int i= 0; i<=x || t>0; ++i ) {
if ( i>x ) {
++x;
}
v[i]+= t;
t= v[i]/10;
v[i]%= 10;
}
for ( int i= x; i>=0; --i ) {
printf( "%lld", v[i] );
}
printf( "\n" );
return 0;
}