记录编号 |
267847 |
评测结果 |
WWWWWWWWWWWWWWWWWWWW |
题目名称 |
[東方S1] 西行寺幽幽子 |
最终得分 |
0 |
用户昵称 |
安呐一条小咸鱼。 |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
0.084 s |
提交时间 |
2016-06-11 17:58:16 |
内存使用 |
0.27 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
using namespace std;
const int N=500;
int _max(const int&a,const int&b)
{
return a>b?a:b;
}
class CBigInt
{
private:
int m_num[N];
int len;
public:
CBigInt()
{
memset(m_num,0,sizeof(m_num));
len=1;
}
CBigInt(const char*ch)
{
memset(m_num,0,sizeof(m_num));
len=strlen(ch);
for(int i=0;i<len;++i)
{
m_num[len-i-1]=ch[i]-'0';
}
}
CBigInt operator +(const CBigInt& x)const
{
CBigInt ret;
int l=max(len,x.len);
ret.len=l;
for(int i=0;i<l;++i)
{
ret.m_num[i]+=m_num[i]+x.m_num[i];
if(ret.m_num[i]>=10)
{
ret.m_num[i+1]=1;
ret.m_num[i]-=10;
}
}
if(ret.m_num[l]!=0)ret.len=l+1;
return ret;
}
CBigInt operator -(const CBigInt& x)const
{
CBigInt ret;
int id,d=0;
for(id=0;id<len;++id)
{
d=m_num[id]+d;
if(d>=x.m_num[id])
{
ret.m_num[id]=d-x.m_num[id];
d=0;
}
else
{
ret.m_num[id]=d+10-x.m_num[id];
d=-1;
}
}
id=len-1;
while(id>0&&ret.m_num[id]==0)--id;
ret.len=id+1;
return ret;
}
CBigInt operator *(const CBigInt& x)const
{
CBigInt ret;
int i,j;
ret.len=len+x.len-1;
for(i=0;i<len;++i)
{
for(j=0;j<x.len;j++)
{
ret.m_num[i+j]+=m_num[i]*x.m_num[j];
if(ret.m_num[i+j]>=10)
{
ret.m_num[i+j+1]+=ret.m_num[i+j]/10;
ret.m_num[i+j]%=10;
}
}
}
if(ret.m_num[ret.len]!=0)ret.len+=1;
return ret;
}
CBigInt operator /(const int& x)
{
CBigInt ret;
int d=0;
int id=len-1;
while(id>=0)
{
d=m_num[id]+d*10;
ret.m_num[id]=d/x;
d=d%x;
--id;
}
id=len-1;
while(id>0&&ret.m_num[id]==0)--id;
ret.len=id+1;
return ret;
}
bool operator <(const CBigInt&x)
{
if(len<x.len)return true;
if(len>x.len)return false;
int id=len;
while(id>=0)
{
if(m_num[id]<x.m_num[id])return true;
if(m_num[id]>x.m_num[id])return false;
--id;
}
return false;
}
bool operator <=(const CBigInt&x)
{
if(len<x.len)return true;
if(len>x.len)return false;
int id=len;
while(id>=0)
{
if(m_num[id]<x.m_num[id])return true;
if(m_num[id]>x.m_num[id])return false;
--id;
}
return true;
}
void Print() const
{
for(int i=len-1;i>=0;--i)
{
printf("%d",m_num[i]);
}
puts("");
}
};
CBigInt a;
void Init()
{
char a_[2000010]="\0";
scanf("%s",a_);
a=a_;
}
int main()
{
freopen("spring.in","r",stdin);
freopen("spring.out","w",stdout);
int b;
Init();
cin>>b;
CBigInt c=a/b;
c.Print();
return 0;
}