比赛 |
2022级数学专题练习赛6 |
评测结果 |
AAAAAAAAAA |
题目名称 |
神奇口袋 |
最终得分 |
100 |
用户昵称 |
op_组撒头屯 |
运行时间 |
0.028 s |
代码语言 |
C++ |
内存使用 |
3.84 MiB |
提交时间 |
2023-01-23 22:26:21 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define qi queue<int>
#define sti stack<int>
#define fi first
#define se second
#define pb push_back
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
const int N=1000+5;
int n,m,d;
unordered_map<int,int>s[2];
int a[N],tot=0;
void mul(int x,int id){
for (int i=2;i*i<=x;i++){
if (x%i==0){
while(x%i==0){
s[id][i]++;x/=i;
}
}
}
if (x!=1)s[id][x]++;
return ;
}
int f[N*N],tp;
void px(int x){
int jw=0;
for (int i=1;i<=tp;i++){
f[i]=f[i]*x+jw;
jw=f[i]/10;f[i]%=10;
}
while(jw){
f[++tp]=jw%10;jw/=10;
}
}
int main(){
freopen ("bag.in","r",stdin);
freopen ("bag.out","w",stdout);
scanf("%d%d%d",&n,&m,&d);
for (int i=1;i<=n;i++){
scanf("%d",&a[i]);tot+=a[i];
}
for (int i=1;i<=m;i++){
int x,y;scanf("%d%d",&x,&y);
mul(a[y],0);mul(tot,1);
a[y]+=d;tot+=d;
}
unordered_map<int,int>::iterator it;
for (it=s[0].begin();it!=s[0].end();it++){
int x=it->first,y=it->second,z=s[1][x];
if (z){
s[0][x]-=min(y,z);s[1][x]-=min(y,z);
}
}
memset(f,0,sizeof(f));
f[1]=1;tp=1;
for (it=s[0].begin();it!=s[0].end();it++){
int x=it->first,y=it->second;
if (!y)continue;
for (int j=1;j<=y;j++)px(x);
}
for (int i=tp;i>=1;i--)printf("%d",f[i]);
printf("/");
memset(f,0,sizeof(f));
f[1]=1;tp=1;
for (it=s[1].begin();it!=s[1].end();it++){
int x=it->first,y=it->second;
if (!y)continue;
for (int j=1;j<=y;j++)px(x);
}
for (int i=tp;i>=1;i--)printf("%d",f[i]);
printf("\n");
}