Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
28381 liuyile 【BJ】T3 C++ 解答错误 0 876 MS 262156 KB 1093 2024-04-14 15:01:42

Tests(0/10):


#include <bits/stdc++.h> using namespace std; #define int long long //#define endl "\n" int m[510],v[510]; int n; int s[70003]; vector<int>P={2,3,5,7,11,13,17,19}; const int p=8; map<int,int>mp; int cnt=0; inline void dfs(int dep,int prod){ // cout<<dep<<" "<<prod<<endl; if(dep==p){ mp[prod]=++cnt; s[cnt]=prod; return ; } int ct=1; while(ct<=500){ dfs(dep+1,prod*ct); ct*=P[dep]; } } int f[70000]; map<int,int>g[70000]; signed main(){ ios::sync_with_stdio(0); // freopen("sequence.in","r",stdin); // freopen("sequence.out","w",stdout); dfs(0,1); cout<<cnt<<endl; cin>>n; for(int i=1;i<=n;i++){ int x,v,w; cin>>x>>v; w=1; for(int p:P)while(x%p==0)x/=p,w*=p; for(int i=1;i<=cnt;i++) if(s[i]%w==0){ if(x==1)f[i]+=v; else g[i][x]+=v; } } int res=0; for(int i=1;i<=cnt;i++){ int ct=f[i]; // if(ct)cout<<i<<" "<<s[i]<<" "<<f[i]<<endl; for(auto e:g[i])ct+=max(e.second,0ll); res=max(res,ct); } cout<<res<<endl; cout.flush(); fflush(stdout); return 0; }


测评信息: