Bessie Goes Moo(暴力)

Bessie Goes Moo

题目传送门

Bessie Goes Moo

题目大意

一共七个字符,分别为 B E S I G O M BESIGOM BESIGOM
给你n个每个字符对应的数字,可能一个字符对应多个整数
求满足 ( B + E + S + S + I + E ) ( G + O + E + S ) ( M + O + O ) % 7 = 0 (B+E+S+S+I+E)(G+O+E+S)(M+O+O)\%7=0 (B+E+S+S+I+E)(G+O+E+S)(M+O+O)%7=0的情况数

思路

对输入的数,可以先进行取模,即对7模数相同的可以看做一个数
然后直接 O ( n 7 ) O(n^7) O(n7)暴力模拟即可

AC Code

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<set>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f
#define int long long
// #define TDS_ACM_LOCAL
const int N=2e5 +9;
char s;
int n, m;
int flag[10][N];
set<int> a[10];
void solve(){
    cin>>n;
    string tep="BESIGOM";
    for(int i=1; i<=n; i++){
        cin>>s>>m;
        m=(m%7+7)%7;
        int j;
        for(j=0; j<7; j++)  if(tep[j]==s)   break;
        a[j].insert(m);
        flag[j][m]++;
    }
    int ans=0;
    for(auto b:a[0])
        for(auto e:a[1])
            for(auto s:a[2])
                for(auto i:a[3])
                    for(auto g:a[4])
                        for(auto o:a[5])
                            for(auto m:a[6])
                                if((b+e+s+s+i+e)*(g+o+e+s)*(m+o+o)%7==0)
                                    ans+=flag[0][b]*flag[1][e]*flag[2][s]*flag[3][i]*flag[4][g]*flag[5][o]*flag[6][m];
    cout<<ans<<endl;
    return ;
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
#ifdef TDS_ACM_LOCAL
    freopen("D:\\VS code\\.vscode\\testall\\in.txt", "r", stdin);
    freopen("D:\\VS code\\.vscode\\testall\\out.txt", "w", stdout);
#endif
    solve();
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值