Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我这个也是1001的,但是就是不过,请哪位达人帮看看还有什么数据过不了.实在找不到了.#include<stdio.h> #include<stdlib.h> #include<memory.h> int * ret = NULL; void print_ret(int,int,int); void mul(int*,int); int main(void) { char R[6]; char num[2]; char h_num = '0'; char l_num = '0'; int source = 0; int int_bit = 0; int zero_bit = 0; int N = 0; int i =0; int * submut = NULL; memset(R,0,6); memset(num,0,2); scanf("%s%s",R,num); if(num[1] == 0) N = num[0] -48; else N = (num[0] - 48) * 10 + num[1] - 48; if(N < 1 || N > 25) { return 0; } for(i = 0 ;i<6; i++) { if(R[i] != '.') { source = source * 10 + R[i] - 48; } else { continue; } } i =5; while(R[i] != '.') { if(R[i] == '0') { zero_bit++; i --; } else { break; } } i = 0; while(R[i] != '.') { int_bit ++; i ++; } if(int_bit >=3) { return 0; } submut = (int *)malloc(5 * sizeof(int)); memset(submut,0,5 * sizeof(int)); for(i =0 ;i < 5; i++) { submut[i] = source %10; source = source/10; } ret = (int *)malloc(1 * sizeof(int)); memset(ret,0,1 * sizeof(int)); *ret = 1; for(i = 1; i<= N; i ++) { mul(submut,i); } print_ret(int_bit,N,zero_bit); printf("\n"); return 0; } void mul(int * submut,int i) { int * res = NULL; int * cal_arr[5]; int col = 0; int row = 0; int tmp_val = 0; int flag = 0; res = (int *)malloc(i * 5 * sizeof(int)); memset(res,0,i * 5 * sizeof(int)); for (col =0 ;col <5; col ++) { cal_arr[col] = (int*)malloc(i * 5 * sizeof(int)); memset(cal_arr[col], 0, i * 5 * sizeof(int)); } for (row = 0 ; row <5; row ++) { for(col = 0 ; col <=(i-1) * 5 ; col ++) { tmp_val = ret[col] * submut[row] + flag; cal_arr[row][col + row] = tmp_val % 10; flag = tmp_val /10; } cal_arr[row][col + row] = flag; flag = 0; } flag = 0; for(col = 0; col < i * 5 ; col ++) { tmp_val = cal_arr[0][col] + cal_arr[1][col] + cal_arr[2][col] +cal_arr[3][col] + cal_arr[4][col] + flag; res[col] = tmp_val %10; flag = tmp_val /10; } res[col] = flag; ret = res; } void print_ret(int bit,int n,int flag) { int i = 0; for(i=n * 5; i >=(5 - bit) * n ; i --) { if(ret[i] != 0) { break; } } if (i < (5 - bit)*n) { printf("."); for(;i >=0;i--) { printf("%d",ret[i]); } } else { if(flag != 0) { for(; i>= flag * n ; i --) { if( (i == (5-bit) * n -1) && ((5-bit) * n -1 >= flag * n)) printf("."); printf("%d",ret[i]); } } else { for(; i>= 0; i--) { if(i == (5 - bit)*n - 1) printf("."); printf("%d",ret[i]); } } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator