hdu 1230 runtime 为何

#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;
int b[30];
int c[30];

//int prime()
//{
//    int i,j,t,k,q;
//    a[0]=2;t=1;
//    for(i=3;i<=100;i+=2)
//    {
//        q=(int)sqrt(i);k=1;
//        for(j=0;a[j]<q && j<t;j++)
//           {
//                if(i%a[j]==0)
//                {
//                   k=0;break;            
//                }           
//           }
//           if(k) a[t++]=i;                   
//    }
//    for(i=0;i<=t;i++)
//      printf("%d \n",a[i]);//素数打表    
//}


int s(int t[30],int string)
{
      int i,j,w;
      for(i=0,j=string-1;i<j;i++,j--)
      {
          w=t[i];
          t[i]=t[j];
          t[j]=w;                              
      }
}
int main()
{
    int a[30]={2,3,5,7,11,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    while(1)
    {
      int m,n,i,j,k,p,q,t;char ch,dh=',';
      j=0;i=0;
       memset(b,0,sizeof(b));memset(c,0,sizeof(c));
       while(ch!=' ')
                scanf("%d%c",&b[j++],&ch);
       while(ch!='\n')
                 scanf("%d%c",&c[i++],&ch);
        if(i==1 && j==1 && b[0]==0 && c[0]==0)
            return 0;
       s(b,j);s(c,i);
       q=j;
       if(j<i) q=i;
       for(i=0;i<=q;i++)
          {
                 b[i]=b[i]+c[i];
                 if(b[i]>=a[i]) {
                                   t=b[i]/a[i];
                                   b[i]%=a[i];
                                   b[i+1]+=t;
                                }      
          }
          if(b[q]!=0)
               for(i=q;i>=0;i--)
                     {
                           if(i!=0)
                              printf("%d%c",b[i],dh);
                            else
                               printf("%d\n",b[i]);          
                     }
          else{
                   for(i=q-1;i>=0;i--)
                      {
                          if(i!=0)
                              printf("%d%c",b[i],dh);
                          else
                              printf("%d\n",b[i]);
                      }
               }
          }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

洋葱ycy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值