Pagini recente » Cod sursa (job #2251932) | Cod sursa (job #2542240) | Cod sursa (job #850409) | Cod sursa (job #1530383) | Cod sursa (job #1236908)
#include <cstdio>
#include <cstring>
using namespace std;
char s[1000005];
bool rasp;
class HUGE {
private:
int x[1000001];
public:
HUGE() {
memset(x,0,sizeof(x));
x[0]=1;
}
HUGE(bool sss) {
gets(s);
int nn;
x[0]=strlen(s);
nn=x[0]-1;
for(int i=1; i<=x[0]; ++i) {
x[i]=s[nn]-'0';
--nn;
}
}
HUGE(const HUGE& other) {
memcpy(x,other.x,sizeof(other.x));
}
HUGE (long long n) {
memset(x,0,sizeof(x));
x[0]=0;
do {
x[++x[0]]=1LL*n%10;
n=1LL*n/10;
} while(n);
}
int cmp(const HUGE& other) {
if(x[0]<other.x[0]) return -1;
else if(x[0]>other.x[0]) return 1;
for(int i=x[0]; i>=0; --i)
if(x[i]<other.x[i]) return -1;
else if(x[i]>other.x[i]) return 1;
return 0;
}
void print() {
for(int i=x[0]; i>=1; --i) printf("%d",x[i]);
printf("\n");
}
HUGE operator *=(const long long& other);
HUGE operator /=(long long kk);
bool operator ==(const HUGE& other);
HUGE operator +=(bool po);
};
/*HUGE HUGE::operator *(const HUGE& other) {
HUGE c;
c.x[0]=x[0]+other.x[0]-1;
int i,j,t;
for(i=1; i<=x[0]; ++i)
for(j=1; j<=other.x[0]; ++j)
c.x[i+j-1]+=x[i]*other.x[j];
t=0;
for(i=1; i<=c.x[0]; ++i) {
t=t+c.x[i];
c.x[i]=t%10;
t/=10;
}
int l=c.x[0];
while(t) {
++l;
c.x[l]=t%10;
t/=10;
}
c.x[0]=l;
return c;
}*/
HUGE HUGE::operator *=(const long long& other) {
for(int i=1;i<=x[0];++i){
x[i]*=other;
}
int tr=0,k,k1;
for(int i=1;i<=x[0];++i){
k=x[i]+tr;
x[i]=k%10;
tr=k/10;
}
k=x[0];
while(tr){
++k;
x[0]=k;
x[k]=tr%10;
tr/=10;
}
return *this;
}
HUGE HUGE::operator /=(long long kk) {
int r=0,i;
for(i=x[0]; i>0; --i) {
r=r*10+x[i];
x[i]=1LL*r/kk;
r=1LL*r%kk;
}
while(x[0]>1&&!x[x[0]]) --x[0];
rasp=r;
return *this;
}
inline bool HUGE:: operator ==(const HUGE& other) {
if((*this).cmp(other)!=0)
return 0;
return 1;
}
HUGE HUGE:: operator +=(bool po) {
x[1]++;
for(int i=1; i<=x[0]; ++i) {
if(x[i]>10) {
x[i+1]++;
x[i]-=10;
}
}
if(x[x[0]+1]==1) {
x[0]++;
}
return *this;
}
int main() {
freopen("next.in","r",stdin);
freopen("next.out","w",stdout);
long long k;
bool po;
bool sss;
HUGE A(sss);
scanf("%lld",&k);
A/=k;
if(!rasp) {
A.print();
} else {
A+=po;
A*=k;
A.print();
}
return 0;
}