zoukankan      html  css  js  c++  java
  • 【数论】【HDU 2048】神、上帝以及老天爷 【错排公式】

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2048

    没想到还真的有意外之喜,发现了自己的盲区,其实这道题我在大一的时候是见过的,但是当时不会就给跳过了

    缘,妙不可言~

    错排公式

     1 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 
     5 #define ll long long
     6 #define max3(a,b,c) fmax(a,fmax(b,c))
     7 #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     8 
     9 int main()
    10 {
    11     ll a[22];
    12     a[0] = 0;
    13     a[1] = 0;
    14     a[2] = 1;
    15     for(int i = 3;i <= 20;i++)
    16     {
    17         a[i] = (i-1)*(a[i-1] + a[i-2]);
    18     }
    19     int c,temp;
    20     cin >> c;
    21     while(c--)
    22     {
    23         scanf("%d",&temp);
    24         ll s = 1;
    25         for(int i = 1;i <= temp;i++)
    26         {
    27             s *= i;
    28         }
    29         printf("%.2lf%%
    ",(double)(a[temp]*1.0)*100.0/s);
    30     }
    31     
    32     return 0;
    33 }
    文章搬运自我的个人博客http://duny31030.top 原博客为静态博客,因备份丢失无法继续更新,所以又搬运回博客园,可能部分文章阅读体验不好,可以到我的静态博客搜索相同标题查看
  • 相关阅读:
    MFC列表控件更改一行的字体颜色
    MFC之sqlite
    MFC笔记10
    MFC---关于string.h相关函数
    MFC笔记8
    MFC笔记7
    MFC笔记6
    MFC笔记5
    MFC笔记4
    MFC笔记3
  • 原文地址:https://www.cnblogs.com/duny31030/p/8963356.html
Copyright © 2011-2022 走看看