TJU1091

只要两个数加法不产生进位就能满足题意。对于首位来说,可以有8*9/2=36种选数方式(因为首位不为0),对于其他位来说,可以有9*10/2=55种选数方式,乘法原理以后,剩下来的就是大数乘法和输出了。
None.gif #include < iostream >
None.gif
using   namespace  std;
None.gif
None.gif
const   int  MAX  =   100 ;
None.gif
class  Num
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif
public:
InBlock.gif    Num(
int n);
InBlock.gif    Num 
operator *(int a);
InBlock.gif    
void Print();
InBlock.gif
private:
InBlock.gif    
int data[MAX];
ExpandedBlockEnd.gif}
;
None.gif
int  main()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
int n;
InBlock.gif    
while(cin>>n)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        Num a(
36);
InBlock.gif        
for(;n>1;n--) a=a*55;
InBlock.gif        a.Print();
ExpandedSubBlockEnd.gif    }

InBlock.gif    
return 0;
ExpandedBlockEnd.gif}

None.gifNum::Num(
int  n)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
int t;
InBlock.gif    data[MAX
-1]=n;
InBlock.gif    
for(t=MAX-2;t>=0;t--)
InBlock.gif        data[t]
=0;
ExpandedBlockEnd.gif}

None.gifNum Num::
operator   * ( int  a)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
int t,mem=0;
InBlock.gif    Num b(
0);
InBlock.gif    
for(t=MAX-1;t>=0;t--)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        b.data[t]
=a*data[t]+mem;
InBlock.gif        mem
=b.data[t]/10;
InBlock.gif        b.data[t]
%=10;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
return b;
ExpandedBlockEnd.gif}

None.gif
void  Num::Print()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
int t;
InBlock.gif    
for(t=0;t<MAX-1;t++)
InBlock.gif        
if(data[t]>0break;
InBlock.gif    
for(;t<MAX;t++)
InBlock.gif        cout
<<data[t];
InBlock.gif    cout
<<endl;
ExpandedBlockEnd.gif}

转载于:https://www.cnblogs.com/FancyMouse/articles/259634.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值