OIES公式合集

求满足条件的集合方案数量
  1. A, B的交集不能为空集
  2. A, B不能相互包含(A=B也属于相互包含)

注意:在这里我们认为(A,B)是无序的,即(A,B)和(B,A)是同一种方案
求总方案的数量

{0, 0, 0, 3, 30, 195, 1050, 5103, 23310, 102315, 437250, 1834503, 7597590, 31175235, 127067850, 515396703, 2083011870, 8396420955, 33779000850, 135696347703, 544527210150, 2183335871475, 8749027724250, 35043169903503, 140313869216430, 561679070838795}

公式 : \frac {4^n-4*3^n+6*2^n-4} {8}

代码 :

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 100000007;


ll ppow(ll a, ll b) {
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b&1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

ll inv(ll a, ll mod) {
    return ppow(a, mod-2);
}

int main() {
    ll n;
    scanf("%lld", &n);
    n += 1;
    ll ans;
    ll inv_8 = inv(8, mod);
    ans = (ppow(4,n)%mod+(-4*ppow(3,n)+mod)%mod+6*ppow(2,n)%mod-4 + mod) %mod * inv_8 % mod;
    printf("%lld\n", ans%mod);
    return 0;
}

高度为n的大正三角形中 正三角形的个数

[图片上传失败...(image-7fea76-1542678378768)]

{0, 1, 5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365, 1820, 2380, 3060, 3876, 4845, 5985, 7315, 8855, 10626, 12650, 14950, 17550, 20475, 23751, 27405, 31465, 35960, 40920, 46376, 52360, 58905, 66045, 73815, 82251, 91390, 101270, 111930, 123410}

公式:\frac{ n*(n+1)*(n+2)*(n+3)} {24}

代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll ppow(ll a, ll b) {
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b&1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

ll inv(ll a, ll mod) {
    return ppow(a, mod-2);
}

int main() {
    int T;
    ll n, ans;
    ll inv_24 = inv(24, mod);
    scanf("%d", &T);
    while(T--) {
        scanf("%lld", &n);
        ans = n * (n + 1) % mod * (n + 2) % mod * (n + 3) % mod * inv_24 % mod;
        printf("%lld\n", ans % mod);
    }
    return 0;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 专业考题类型管理运行工作负责人一般作业考题内容选项A选项B选项C选项D选项E选项F正确答案 变电单选GYSZ本规程...
    小白兔去钓鱼阅读 13,087评论 0 13
  • 选择题部分 1.(),只有在发生短路事故时或者在负荷电流较大时,变流器中才会有足够的二次电流作为继电保护跳闸之用。...
    skystarwuwei阅读 14,688评论 0 7
  • 今天是机械培训第二十八天,完成了ppt的制作,改了图纸的一些小细节。课设做完了,后天答辩,明天再熟悉一下,看看还...
    鑫儿luna阅读 1,355评论 0 0
  • 二十出头,一个尴尬的年纪。 在这个年纪里我们想做的事情太多太多,可真正实现的却很...
    T18阅读 3,301评论 0 2
  • 在粥店吃完酱牛肉,想你 在超市购物拎着大包小包,想你 坐在公交车上,看着窗外,想你 回到家里,捧着热气腾腾的杯子,...
    堂前花开阅读 2,720评论 0 2

友情链接更多精彩内容