首页 > 其他分享 >CF449D Jzzhu and Numbers

CF449D Jzzhu and Numbers

时间:2023-07-20 17:44:07浏览次数:25  
标签:limits sum CF449D Jzzhu subseteq Numbers

有一个很蠢但是很好写的做法。

就是你先令 \(t_i\) 为与起来恰好为 \(i\) 的方案数,然后 \(g_i\) 为与起来子集中有 \(i\) 的方案数。

然后 \(g_S=\sum\limits_{T\subseteq S}t_T\),反演一下变成 \(t_{S}=\sum\limits_{T\subseteq S}(-1)^{|S|-|T|}g_{T}\)。注意到可以 \(O(w)\) 枚举 \(T\)。

现在考虑如何求 \(g_T\)。显然与起来包含 \(T\) 意味着所选数都包含 \(T\),令 \(f_{S}=\sum\limits_{S\subseteq T}c_{T}\),\(c_T\) 为 \(a\) 中 \(T\) 的出现次数,那么显然有 \(g_T=2^{f_{T}}-1\)。

然后 \(f_{T}\) 显然就是一个超集和,取反后变成子集和,FWT 即可。

复杂度 \(O(n+w\log w)\),不用什么麻烦的特判。

标签:limits,sum,CF449D,Jzzhu,subseteq,Numbers
From: https://www.cnblogs.com/Ender32k/p/17569106.html

相关文章

  • CF1808C Unlucky Numbers 题解
    可以证明答案是\(l\)或\(r\)的一段前缀,拼上后面全部相同的一段字符\(d\),证明方式类似数位dp。能够自由填的数字一定是相等的,这样不会影响幸运值。前面那些不能自由填写的,就是\(l\)或\(r\)的一段前缀。假如不是\(l\)或\(r\)的一段前缀,必然填写相等的更好,而这种情况已......
  • 题解 CF1842H【Tenzing and Random Real Numbers】
    看了题解。好难受,想用积分求概率,算了半天。发现没啥规律,不是不能算,就是太可怕了。Problem有\(n\)个\([0,1]\)范围内的均匀随机变量\(x_{1\cdotsn}\)和\(m\)条限制,每条限制形如\(x_i+x_j\le1\)或\(x_i+x_j\ge1\)。请你求出所有限制均满足的概率。对\(998244353\)......
  • PROPERTIES OF SQUARE NUMBERS
     Whenanumberismultipliedbyitself,theresultingnumberiscalledasasquarenumber. Forexample,whenwemultiply5by5,weget52 =25.Here,25isasquarenumber.Ingeometry,theareaofasquareisthefinestexampleofasquarenumber.Are......
  • PAT (Advanced Level)_1100 Mars Numbers (20分)(C++_模拟)
    PeopleonMarscounttheirnumberswithbase13:ZeroonEarthiscalled"tret"onMars.Thenumbers1to12onEarthiscalled"jan,feb,mar,apr,may,jun,jly,aug,sep,oct,nov,dec"onMars,respectively.Forthenexthigherdigi......
  • Educational Codeforces Round 150 (Rated for Div. 2) C. Ranom Numbers
    #include<iostream>#include<string>#include<cstring>#include<algorithm>#include<cmath>usingnamespacestd;constintN=2e5+10;typedeflonglongll;//记录每个字母的最前面的位置和最后面的位置intFast[5],End[5];strings,c;llres=-0x3......
  • CodeForces 1841C Ranom Numbers
    洛谷传送门CF传送门先反转\(s\)串,然后考虑dp,设\(f_{i,j,0/1}\)为考虑了\([1,i]\),前缀最大值为\(j\),是否修改过字符的最大得分。转移讨论是否在这个位置修改即可。时间复杂度\(O(n)\)。code//Problem:C.RanomNumbers//Contest:Codeforces-Educational......
  • Codeforces Round #232 (Div. 2)-B. On Corruption and Numbers
    原题链接B.OnCorruptionandNumberstimelimitpertestmemorylimitpertestinputoutputAlexey,amerryBerlandentrant,gotsickofthegrayrealityandhezealouslywa......
  • django 中存储手机号的字段, 使用 Django 库 pip install django-phonenumber-field[ph
    原文参见:https://www.delftstack.com/zh/howto/django/django-phone-number-field/使用第三方Django应用程序的 PhoneNumberField 存储电话号码要存储电话号码,我们可以使用实现此字段的第三方Django应用程序或库:PhoneNumberField。你可以在此处找到此库或应用程序的Git......
  • [LeetCode] 1351. Count Negative Numbers in a Sorted Matrix
    Givena mxn matrix grid whichissortedinnon-increasingorderbothrow-wiseandcolumn-wise,return thenumberof negative numbersin grid.Example1:Input:grid=[[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]Output:8Explanation:Thereare......
  • upc 8378: Floating-Point Numbers(模拟浮点数运算)
    8378:Floating-PointNumbers时间限制:1Sec  内存限制:128MB提交:10  解决:4[提交][状态][讨论版][命题人:admin]题目描述Inthisproblem,weconsiderfloating-pointnumberformats,datarepresentationformatstoapproximaterealnumbersoncomputers.S......