牛客“迎新春,过大年”多校程序设计竞赛A题
题目描述:
这里有个小trick
当时也看到数据范围的问题了
我们考虑不同的数
不同的数最多有
#include <bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define pii pair<int, int>
#define ll long long
#define db double
#define endl '\n'
#define x first
#define y second
#define pb push_back
using namespace std;
void solve()
{
int n;cin>>n;
map<int,int>p;
//map去重
rep(i,1,n){
int x;cin>>x;
p[x]++;
}
//统计贡献
int ans=0;
const int mod=998244353;
for(auto [i,cnt1]:p){
for(auto [j,cnt2]:p){
ans=(ans+__gcd(i,j)*(__builtin_popcount(i)+__builtin_popcount(j))%mod*cnt1%mod*cnt2%mod)%mod;
}
}
cout<<ans<<endl;
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// freopen("1.in", "r", stdin);
int _;
// cin>>_;
// while(_--)
solve();
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署