Pagini recente » Cod sursa (job #403683) | Cod sursa (job #3258898) | Cod sursa (job #1027442) | Cod sursa (job #3039654) | Cod sursa (job #1958277)
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std ;
class Huge : protected vector<int>{
private:
static const int SIZE = 400002;
static const int BASE = 1000;
static const int EXP = 3;
public:
inline Huge();
inline Huge(char N[]);
inline void print();
inline void operator *= (long long B);
inline void operator /= (long long B);
inline long long operator % (long long B);
};
#define A (*this)
inline Huge :: Huge(){
A.resize(SIZE);
}
inline Huge :: Huge(char N[]){
A.resize(SIZE); A[0] = 0;
for(int length = strlen(N); length > 0; length -= EXP){
A[0]++;
for(int i = max(0, length - EXP); i < length; i++){
A[A[0]] = A[A[0]] * 10 + N[i] - '0';
}
}
}
inline void Huge :: print(){
printf("%d", A[A[0]]);
for(int i = A[0] - 1; i > 0; i--){
printf("%03d", A[i]); // %0EXPd
}//printf("\n");
}
inline void Huge :: operator *= (long long B){
long long t = 0;
for (int i = 1; i <= A[0]; ++i) {
t = 1LL * A[i] * B + t;
A[i] = t % BASE;
t /= BASE;
}
while (t) {
A[++A[0]] = t % BASE;
t /= BASE;
}
}
inline void Huge :: operator /= (long long B){
long long carry = 0;
for(int i = A[0]; i > 0; i--, carry %= B)
A[i] = (carry = carry * BASE + A[i]) / B;
for(; A[0] > 1 && !A[A[0]]; A[0]--);
A[1]++;
}
inline long long Huge :: operator % (long long B){
long long carry = 0;
for(int i = A[0]; i > 0; i--)
carry = (carry * BASE + A[i]) % B;
return carry;
}
#undef A
char numberN[1000020];
long long D;
Huge N;
int main(){
freopen("next.in", "r", stdin);
freopen("next.out", "w", stdout);
scanf("%s", numberN);
scanf("%lld", &D);
N = numberN;
if(N % D == 0){
printf("%s", numberN);
return 0;
}
N /= D; N *= D;
N.print();
return 0;
}