Given an integer N(0 ≤ N ≤ 1000),your task is to calculate
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/17 15:11:06
Given an integer N(0 ≤ N ≤ 1000),your task is to calculate
#include
#include
int a[1000][1000];
int main()
{
int i,j,n,f=0;
memset(a,0,sizeof(a));
a[0][1000]=0;
a[1][1000]=1;
for(i=2;i=0;j--)
a[i][j]=a[i-1][j]*i;
for(j=1000;j>=0;j--)
if(a[i][j]>=1000)
{
a[i][j-1]+=a[i][j]/1000;
a[i][j]%=1000;
}
}
while(scanf("%d",&n)!=EOF)
{
f=0;
for(j=0;j
#include
#include
int a[1000][1000];
int main()
{
int i,j,n,f=0;
memset(a,0,sizeof(a));
a[0][1000]=0;
a[1][1000]=1;
for(i=2;i=0;j--)
a[i][j]=a[i-1][j]*i;
for(j=1000;j>=0;j--)
if(a[i][j]>=1000)
{
a[i][j-1]+=a[i][j]/1000;
a[i][j]%=1000;
}
}
while(scanf("%d",&n)!=EOF)
{
f=0;
for(j=0;j
你的算法是有问题的!
明显的错误就是数组越界!
我用java给你写了一个,你做下参考:
public class TestPlus {
public TestPlus() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int task = 100;//要计算的目标数
calcN(task);
}
/**
* 计算task的阶乘
* @param task
*/
private static long calcN(int task) {
// TODO Auto-generated method stub
long result = 0;
switch(task){
case 0:
result = 1;break;
default :
result = calc(task);break;
}
System.out.println("==="+result);
return result;
}
private static long calc(int task) {
// TODO Auto-generated method stub
long result = 1;
for(int i=1;i
明显的错误就是数组越界!
我用java给你写了一个,你做下参考:
public class TestPlus {
public TestPlus() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int task = 100;//要计算的目标数
calcN(task);
}
/**
* 计算task的阶乘
* @param task
*/
private static long calcN(int task) {
// TODO Auto-generated method stub
long result = 0;
switch(task){
case 0:
result = 1;break;
default :
result = calc(task);break;
}
System.out.println("==="+result);
return result;
}
private static long calc(int task) {
// TODO Auto-generated method stub
long result = 1;
for(int i=1;i
Given an integer N(0 ≤ N ≤ 1000),your task is to calculate
Your task is to Calculate a + b.
If is given that N is an integer.Prove that (a) 3(2N-1)+1 is
英语翻译Given any integer 0≤n≤10000 not divisible by 2 or 5,some
杭电ACM1092题目 Problem Description Your task is to Calculate th
C语言的简易编程问题Your task is to Calculate the sum of some integers
英语翻译Is the positive integer n equal to the square of an inte
英语翻译Given an integer array A,which contains N integers.Pleas
英语翻译Your task is to find the sum of all integer numbers lyin
sat2 巴郎if n is an integer,what is the remainder when 3x(2^(n
Problem Description Given a positive integer N,y
Dim i As Integer,n As Integer For i = 0 To 50 i = i + 3 n =