zoukankan      html  css  js  c++  java
  • HDOJ 1042 N!

    万位制,先计算10000!的位数,然后考虑分配多大的数组!

    Accepted  1984MS  240K

     1 # include <stdio.h>
    2 # include <memory.h>
    3
    4 # define N 8200
    5 # define BASE 100000
    6
    7 int main()
    8 {
    9 int n, i, j;
    10 long long c, tmp;
    11 int a[N];
    12
    13 freopen("in.txt", "r", stdin);
    14 freopen("out.txt", "w", stdout);
    15
    16 while (~scanf("%d", &n))
    17 {
    18 memset(a, 0, sizeof(a));
    19 a[0] = 1;
    20 for (i = 1; i <= n; ++i)
    21 {
    22 for (c=0, j=0; j < N; ++j)
    23 {
    24 tmp = a[j]*i + c;
    25 c = tmp / BASE;
    26 a[j] = tmp - c*BASE;
    27 }
    28 }
    29 j = N-1;
    30 while (!a[j]) --j;
    31 printf("%d", a[j--]);
    32 while (j >= 0)
    33 printf("%05d", a[j--]);
    34 printf("\n");
    35 }
    36
    37 return 0;
    38 }
  • 相关阅读:
    DQL-联合查询
    DQL-分页查询
    DQL-子查询
    DQL-分组查询
    DQL-常见的函数
    DQL-排序查询
    DQL-条件查询
    前端底层-js介绍
    HTML8
    HTML7
  • 原文地址:https://www.cnblogs.com/JMDWQ/p/2391190.html
Copyright © 2011-2022 走看看