Pagini recente » Cod sursa (job #1856242) | Cod sursa (job #316632) | Cod sursa (job #1836880) | Cod sursa (job #1492671) | Cod sursa (job #1236765)
#include <iostream>
#include <cstdio>
#include <string>
#include <fstream>
using namespace std;
using namespace std;
const int NMAX = 1000001;
const int BASE = 10;
class HUGE
{
private: int x[NMAX];
public: HUGE(){
memset(x, 0, sizeof(x));
x[0] = 1;
}
HUGE(string s) {
memset(x, 0, sizeof(x));
x[0] = s.size();
for(int i = 0; i < x[0]; ++i) {
x[x[0] - i] = s[i] - '0';
}
}
HUGE &operator + (long long &other) {
long long tr = 0, k;
HUGE temp;
temp.x[0] = x[0];
for(int i = 1; i <= temp.x[0]; ++i) {
k = x[i] + other % BASE + tr;
temp.x[i] = k % BASE;
tr = k / BASE;
other = other / 10;
}
k = temp.x[0];
if(tr) {
++k;
temp.x[0] = k;
temp.x[k] = tr;
}
return temp;
}
long long &operator % (long long &other) {
long long r = 0;
for(int i = x[0]; i > 0; --i){
r = r * 10 + x[i];
r %= other;
}
return r;
}
void print(){
for(int i = x[0]; i >= 1; --i)
cout << x[i];
}
/*void read() {
}*/
};
int main()
{
ifstream cin("next.in");
ofstream cout("next.out");
string s;
cin >> s;
HUGE N(s);
long long D, R;
cin >> D;
R = N % D;
if(R > 0)
R = D - R;
N = N + R;
N.print();
return 0;
}