当前位置:网站首页>A - Eddy's AC puzzle (C language)
A - Eddy's AC puzzle (C language)
2022-06-11 03:57:00 【Luo 907】
One 、 subject
Eddy It's a ACMer, He not only likes to do ACM topic , And for Ranklist Everyone in the ac There is also a certain amount of research , When he is bored, he often puts... On paper Ranklist Everyone in the world ac The number of topics is extracted , Then select some of them ( Or all ) according to ac The quantity of is divided into two groups for comparison , He wants to be the smallest in the first group ac The number is greater than the maximum in the second group ac Count , But there will be many such cases , Smart, do you know how many such situations there are ?
In particular : In order to simplify the problem , Here we assume that the number of people excerpted is n people , And everyone ac The number of will not be equal , The final result is 64 Bit integer range .
Input format :
The input contains multiple sets of data , Each group contains an integer n, From Ranklist The total number of people excerpted from .
Output format :
For each instance , Output the total number of schemes that meet the requirements , One line per output .
Sample
Inputcopy Outputcopy
2
4
1
17
Two 、 Solution
1. Ideas
① Thinking of this topic , First, in the n In the personal , We are free to choose (2~n) personal , Write it down as i, According to the arrangement 
We can get the result of how many permutations and combinations there are , And in each set of results , Because the numbers don't repeat , We can know that there is (i-1) There are different grouping methods .
② The title requires that the results be 64 Bit integer range , So we define that data can be used long long Type or double type , What I'm using here is double.
——————————————
2. Code
#include<stdio.h>
double func(double t)
{
if(t==0)
{
return 1;
}
double x=1;
for(double i=2;i<=t;i++)
{
x *= i;
}
return x;
}
double C(double x,long long y)
{
return func(y)*1.0/func(x)/func(y-x);
}
int main()
{
double n=0;
while(scanf("%lf",&n) != EOF)
{
double sum = 0;
for(double i=2;i<=n;i++)
{
sum += (i-1)*C(i,n);
}
printf("%.0f\n",sum);
}
return 0;
}
边栏推荐
- Build local source 2.0 for Galaxy Kirin server version
- A.前缀极差(C语言)
- Simulation of radar emitter modulated signal
- VIM quickly select a method / function
- Typera+picgo+ common configurations of Tencent cloud cos
- Quel genre de personne est heureuse?
- [数据集]|无人机视角
- Thinkphp3.2.3 deserialization using chain analysis
- Several time synchronization methods of Beidou timing system (GPS timing equipment)
- Notes on redisson distributed lock usage
猜你喜欢

人与人的一些不同
![[network] socket programming](/img/df/2afc300bfc2dd319247a4b75ef7e2c.png)
[network] socket programming

After the installation of Damon database is completed, query whether it is case sensitive

Docker swarm installing MySQL Cluster
![[elt.zip] openharmony paper Club - Data high-throughput lossless compression scheme](/img/ed/4862c937f2d50bcf5d977527a143a6.png)
[elt.zip] openharmony paper Club - Data high-throughput lossless compression scheme

OpenGL Chapter 10 illuminant

Samsung Galaxy S21 ultra and Apple iPhone 13 Pro Max: which one should you choose

OpenGL Chapter 11 multiple light sources

Notes on redisson distributed lock usage

Manual testing cannot be changed to automated testing. What is missing?
随机推荐
SSLStrip 终极版 —— location 劫持
Quel genre de personne est heureuse?
OpenGL Chapter 8 material
Go failing - expected ‘package‘, found ‘EOF‘
密码找回功能可能存在的问题(补充)
Sentence s, paragraph P in VIM text object
编译原理笔记之词法分析器
Host computer development (how to develop host computer)
Student online education and teaching course management system based on SSM framework
[elt.zip] openharmony paper Club - electronic device software update compression
VIM quickly select a method / function
【CNN】|How much position information do convolutional neural networks encode?
unforgettable moments
Implementation of publish and subscribe mode ----- hand tearing JS series
Brew source change
雷达辐射源调制信号仿真(代码)
Build local source 2.0 for Galaxy Kirin server version
BP神经网络C语言实现总结
JMeter piezometric interface programming North
Le tri le plus couramment utilisé de JS - - série JS déchiquetée à la main