1002: Flowers

1002: Flowers
Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lld
Submitted: 105 Accepted: 61
[Submit][Status][Web Board]
Description
Spring is the season of flowers!
Flowerful ahm002 is a girl who loves flowers so much. She also collects a lots of lo dress(which costs ahm001 too much). One day ahm001 picked a brunch of flowers to ahm002. She notices that each of these flowers is unique, and she wants to decorate her dress by putting flower onto the round skirt.

ahm001 needs to calculate, how many ways there are to decorate ahm002’s dress?

Note that two ways are same if they are identical after rotation or reflection.

Input
The first line of input contains the number of test cases T. The descriptions of the test cases follow:

The only line of each test case contains a single integer, the number of the flowers, n(0 < n <= 20).

Output
For each test case, output the number of the ways.

Sample Input 4
1
2
3
4

Sample Output
1
1
1
3

HINT

123 is same as 321 after reflection.

1234 is same as 4123 after rotation.

问题描述:
Flowerful ahm002很喜欢花,Flowerful ahm001一天摘了一束花给她,每束花都不一样,Flowerful ahm002想把这束花围在裙子上一圈,顺序和逆序相同为一种方法,问总共有多少种方法?
分析:
一看就知道这是一个签到的水题,每多一束花n,它可选取的位子就是在前n-1束花围成的圈的中间共n-1种。
AC代码:

using namespace std; 

long long D[25]; 

int main() 
{ 
    int n,x; 
    scanf("%d",&n); 
    D[1]=1; 
    D[2]=1; 
    D[3]=1; 
    for(int i=4;i<=20;i++) 
        D[i]=D[i-1]*(i-1); 
    while(n--) 
    { 
        scanf("%d",&x); 
        cout <<D[x]<<endl; 
    } 
    return 0; 
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值