N - Nunchucks Shop(公式推导+思维)

 

公式推导:

     当n是偶数,m是偶数的时候,举个例子 n=6,m=2时,我们画图表示:

 我们看对称的时候没有重复出现的都是关于中心对称的,那么我们在加上不重复的再除以2不就是C(6,2)的答案吗,那么不重复的怎么求呢,n=6,m=2时,不重复的不就是左边的和对称的右边的一个的组合吗,那就是C(3,1)!

   再想n =6,m=4时,那么我们按照上面的方式思考不重复的,就是中心对称的部分,那么就是

|(1,2),(5,6)|(1,3)(4,6)|(2,3),(4,5)|那就是左三个选两个和右边的对称就是C(3,2)!

   一般情况,如果

1.n是偶数,m是偶数,那么就会有对称的C(n/2,m/2),就是左半对称区间选m/2个;

2.n是奇数,m是偶数,那么n是奇数,如果还满足对称关系也是很好办的那就中间的不要放在两边那就是和1一样,也是C(n/2,m/2),你可能问中间的呢,你没有删除呀,n/2自动下取整,正好出去中间部分哦!

3.n是奇数,m是奇数,那么满足中间对称,把m中的一个刚刚好放在正中间,m剩下的就是偶数,把问题变成了1,那么还是C(n/2,m/2)

4.n是偶数,m是奇数,这个我们就满足不了对称了,直接除以2即可;

综上:.n是偶数,m是奇数,Ans(n,m)=C(n,m)/2;

            其余的就是:Ans(n,m)=(C(n/2,m/2)+C(n,m))/2;

最后上代码: 

#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set>
#include<bitset>
using namespace std;
#define int long long
const int N = 1e3 + 10;
const int INF=0x3f3f3f3f;
const long long LLINF=4e18+5;
typedef long long LL;
typedef pair<int, int> PII;
#define xx first
#define yy second
#define endl '\n' 

struct node
{


//	bool operator<(const node &a) const
//	{
//	}
};
void ClearFloat()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int read() {
    int ret = 0, f = 1;
    char ch = getchar();
    while ('0' > ch || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while ('0' <= ch && ch <= '9') {
        ret = ret * 10 + ch - '0';
        ch = getchar();
    }
    return ret * f;
}
int n,m;
int a[N][N],c[N][N];
signed main()
{
    ClearFloat();
    cin>>n>>m;
    //预处理
    for(int i=0;i<=50;i++)
    {
        a[i][0]=1;
        for(int j=1;j<=i;j++)
        { 
            a[i][j]=a[i-1][j]+a[i-1][j-1];  
        }
    } 
    for(int i=0;i<=50;i++)
    {
        for(int j=0;j<=i;j++)
        {
        if(i%2==0&&j%2==1)
        {
             c[i][j]=a[i][j]/2; 
        }
        else
        {
             c[i][j]=(a[i][j]+a[i/2][j/2])/2;
        }
        }
    }
    int sum=0;
    for(int i=0;i<=m/2;i++)
    {
        if(m-i<=n&&m-i>=0)
        {
            sum+=c[n][i]+c[n][m-i];
        }
    }
    cout<<sum<<endl;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
UCF101是一个动作识别数据集,包含101个不同的动作类别。每个类别有不同数量的样本,具体数目如下: 1. ApplyEyeMakeup: 145 2. ApplyLipstick: 114 3. Archery: 145 4. BabyCrawling: 132 5. BalanceBeam: 134 6. BandMarching: 167 7. BaseballPitch: 150 8. Basketball: 134 9. BasketballDunk: 137 10. BenchPress: 148 11. Biking: 150 12. Billiards: 145 13. BlowDryHair: 123 14. BlowingCandles: 100 15. BodyWeightSquats: 175 16. Bowling: 146 17. BoxJump: 131 18. BoxingPunchingBag: 147 19. BoxingSpeedBag: 148 20. BreastStroke: 148 21. BrushingTeeth: 146 22. CleanAndJerk: 151 23. CliffDiving: 141 24. CricketBowling: 145 25. CricketShot: 150 26. CuttingInKitchen: 150 27. Diving: 147 28. Drumming: 166 29. Fencing: 145 30. FieldHockeyPenalty: 156 31. FloorGymnastics: 173 32. FrisbeeCatch: 143 33. FrontCrawl: 156 34. GolfSwing: 166 35. Haircut: 139 36. HammerThrow: 139 37. HandstandPushups: 137 38. HandstandWalking: 166 39. HeadMassage: 144 40. HighJump: 145 41. HorseRace: 155 42. HorseRiding: 150 43. HulaHoop: 140 44. IceDancing: 147 45. JavelinThrow: 148 46. JugglingBalls: 166 47. JumpingJack: 151 48. JumpRope: 154 49. Kayaking: 116 50. Knitting: 100 51. LongJump: 140 52. Lunges: 146 53. MilitaryParade: 138 54. Mixing: 147 55. MoppingFloor: 151 56. Nunchucks: 118 57. ParallelBars: 149 58. PizzaTossing: 100 59. PlayingCello: 150 60. PlayingDaf: 100 61. PlayingDhol: 100 62. PlayingFlute: 149 63. PlayingGuitar: 147 64. PlayingPiano: 150 65. PlayingSitar: 100 66. PlayingTabla: 100 67. PlayingViolin: 148 68. PoleVault: 145 69. PommelHorse: 145 70. PullUps: 150 71. Punch: 150 72. PushUps: 150 73. Rafting: 100 74. RockClimbingIndoor: 155 75. RopeClimbing: 141 76. Rowing: 150 77. SalsaSpin: 150 78. ShavingBeard: 144 79. Shotput: 146 80. SkateBoarding: 144 81. Skiing: 146 82. Skijet: 100 83. SkyDiving: 144 84. SoccerJuggling: 133 85. SoccerPenalty: 152 86. StillRings: 145 87. SumoWrestling: 145 88. Surfing: 147 89. Swing: 150 90. TableTennisShot: 145 91. TaiChi: 106 92. TennisSwing: 145 93. ThrowDiscus: 145 94. TrampolineJumping: 145 95. Typing: 144 96. UnevenBars: 144 97. VolleyballSpiking: 149 98. WalkingWithDog: 152 99. WallPushups: 145 100. WeightedSquat: 147 101. Windsurfing: 143
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值