您当前的位置: 首页 >  数学

MangataTS

暂无认证

  • 0浏览

    0关注

    423博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

AcWing 1875. 贝茜的报复(数学+暴力枚举)

MangataTS 发布时间:2022-02-06 20:52:48 ,浏览量:0

题目连接

https://www.acwing.com/problem/content/1877/

思路

我们顺着不太好计算,所以我们反着计算,计算出所有满足条件的奇数个数,然后相乘就好了,复杂度为 O ( N 4 ) O(N^4) O(N4),

代码
#include
using namespace std;
//----------------自定义部分----------------
#define ll long long
#define int long long
#define mod 1000000007
#define endl "\n"
#define PII pair

int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};

ll ksm(ll a,ll b) {
	ll ans = 1;
	for(;b;b>>=1LL) {
		if(b & 1) ans = ans * a % mod;
		a = a * a % mod;
	}
	return ans;
}

ll lowbit(ll x){return -x & x;}

const int N = 100+10;
//----------------自定义部分----------------
int n,m,q;
vector a[8];
/*
不难发现表达式为(2E+2S+I+B)*(G+O+E+S)*(M+2O)
那么我们只需要求出结果为奇数的可能情况就行,也就是I+B、G+O+E+S、M都为奇数的情况
*/

signed main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	
	string op;
	cin>>n;
	int x;
	for(int i = 1;i >op>>x;
		if(op == "B") a[1].push_back(x);
		else if(op == "E") a[2].push_back(x);
		else if(op == "S") a[3].push_back(x);
		else if(op == "I") a[4].push_back(x);
		else if(op == "G") a[5].push_back(x);
		else if(op == "O") a[6].push_back(x);
		else if(op == "M") a[7].push_back(x);
	}
	ll ans = 1;
	//计算每个字母的个数,顺便求出总可能数
	for(int i = 1;i             
关注
打赏
1665836431
查看更多评论
0.0940s