Topcoder SRM 638 DIV 2 (大力出奇迹)_html/css_WEB-ITnose

水题,就是一个暴力。大力出奇迹。

Problem Statement

  There is a narrow passage. Inside the passage there are some wolves. You are given a vector size that contains the sizes of those wolves, from left to right.

The passage is so narrow that some pairs of wolves cannot pass by each other. More precisely, two adjacent wolves may swap places if and only if the sum of their sizes is maxSizeSum or less. Assuming that no wolves leave the passage, what is the number of different permutations of wolves in the passage? Note that two wolves are considered different even if they have the same size.

Compute and return the number of permutations of wolves that can be obtained from their initial order by swapping a pair of wolves zero or more times.

Definition

  Class: NarrowPassage2Easy Method: count Parameters: vector , int Returns: int Method signature: int count(vector size, int maxSizeSum) (be sure your method is public)

Limits

  Time limit (s): 2.000 Memory limit (MB): 256

Constraints

size will contain between 1 and 6 elements, inclusive. – Each element in size will be between 1 and 1,000, inclusive. – maxSizeSum will be between 1 and 1,000, inclusive.

Examples

0)     @@######@@

{1, 2, 3}

登录后复制登录后复制登录后复制 From {1, 2, 3}, you can swap 1 and 2 to get {2, 1, 3}. But you can’t get other permutations. 1)     @@######@@ @@######@@

Returns: 2

登录后复制 Here you can swap any two adjacent wolves. Thus, all 3! = 6 permutations are possible. 2)     @@######@@

{1, 2, 3}

登录后复制登录后复制登录后复制 You can get {1, 2, 3}, {2, 1, 3} and {2, 3, 1}. 3)     @@######@@

1000

登录后复制登录后复制 All of these wolves are different, even though their sizes are the same. Thus, there are 6! different permutations possible. 4)     @@######@@

Returns: 6

登录后复制 5)     @@######@@ @@######@@

{1, 2, 3}

登录后复制登录后复制登录后复制

Returns: 3

登录后复制

{1,1,1,1,1,1}

登录后复制

Returns: 720

登录后复制

{2,4,6,1,3,5}

登录后复制

Returns: 60

登录后复制

{1000}

登录后复制

1000

登录后复制登录后复制

Returns: 1

登录后复制

#include #include #include #include #include #include #include #include #include #include #include #include #define eps 1e-10///#define M 1000100///#define LL __int64#define LL long long#define INF 0x7fffffff#define PI 3.1415926535898#define zero(x) ((fabs(x) size, int maxSizeSum)    {        int len = size.size();        memset(vis, 0, sizeof(vis));        for(int i = 1; i  maxSizeSum)                {                    ///vis[i][j] = 1;                    vis[j][i] = 1;                }            }        }        for(int i = 1; i  maxSizeSum) return 1;            return 2;        }        if(len == 3)        {            for(int i = 1; i  f;    f.push_back(189);    f.push_back(266);    cout

登录后复制

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/3093454.html

(0)
上一篇 2025年3月28日 14:37:28
下一篇 2025年3月28日 14:37:37

AD推荐 黄金广告位招租... 更多推荐

发表回复

登录后才能评论