zoukankan      html  css  js  c++  java
  • Luogu3802 小魔女帕琪 (排列组合)

    注意除数为0情况

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #define R(a,b,c) for(register int  a = (b); a <= (c); ++ a)
    #define nR(a,b,c) for(register int  a = (b); a >= (c); -- a)
    #define Max(a,b) ((a) > (b) ? (a) : (b))
    #define Min(a,b) ((a) < (b) ? (a) : (b))
    #define Fill(a,b) memset(a, b, sizeof(a))
    #define Abs(a) ((a) < 0 ? -(a) : (a))
    #define Swap(a,b) a^=b^=a^=b
    #define ll long long
    
    #define ON_DEBUG
    
    #ifdef ON_DEBUG
    
    #define D_e_Line printf("
    
    ----------
    
    ")
    #define D_e(x)  cout << #x << " = " << x << endl
    #define Pause() system("pause")
    #define FileOpen() freopen("in.txt","r",stdin);
    
    #else
    
    #define D_e_Line ;
    #define D_e(x)  ;
    #define Pause() ;
    #define FileOpen() ;
    
    #endif
    
    struct ios{
        template<typename ATP>ios& operator >> (ATP &x){
            x = 0; int f = 1; char c;
            for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-')  f = -1;
            while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
            x*= f;
            return *this;
        }
    }io;
    using namespace std;
    
    long long a[8];
    int main(){
    	int n = 0;
    	R(i,1,7){
    		io >> a[i];
    		if(a[i] == 0){
    			printf("0.000");
    			return 0;
    		}
    		n += a[i];
    	}
    	
    	double s = 1;
    	R(i,2,7) s *= i;
    	
    	R(i,1,7){
    		s = s * (double)a[i] / (double)(n - i + 1);
    	}
    	printf("%.3lf", (double)s * (n - 6));
    	
    	return 0; 
    } 
    

  • 相关阅读:
    08-JS中table隔行换色
    07-JS中 li 排序
    HTML DOM 事件
    JavaScript 事件
    jQuery事件函数
    JQuery与JS对象相互转换
    jQuery中的选择器
    jQuery实现放大镜特效
    java线程(2016-4-7)
    Java 线程的转换及状态
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11259317.html
Copyright © 2011-2022 走看看