HDU1042 N! 一直Wrong Answer,希望有空的大牛能帮我看看代码!
题目:
HDU1042(N!)wrongAnswer

这里贴上我的代码:
#include
#include
#define Me(a) memset(a,0,sizeof(a))
using namespace std;
const int M=100000;
int a[M];
int Ret(int& x)
{
int i,t,j=0;//j进位
for(i=0;;i++)
{
if(i>=x&&j==0) break;
t=a[i]+j;
j=t/10;
a[i]=t%10;
}
x=i;
}
int main()
{
int n;
while(cin>>n)
{
Me(a);
int x,i,f,t;
x=n;
for(i=0;x;i++) //i记录最高位-1
{
a[i]=x%10;
x/=10;
}
for(f=n-1;f>1;f–)
{
for(t=0;t<i;t++)
{
a[t]*=f;
}
Ret(i);//调整数组
}
for(f=i-1;f>=0;f–) cout<<a[f];
cout<<endl;
}
return 0;
}

相关文章:

  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2021-10-09
  • 2021-10-28
  • 2021-06-28
  • 2022-01-07
  • 2022-12-23
猜你喜欢
  • 2021-06-21
  • 2021-09-26
  • 2022-01-19
  • 2021-08-19
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案