标签:bsp pen span max include algo std lag play
写的有点乱
#include <iostream> #include <string.h> #include <cstdio> #include <algorithm> #include <cstdlib> #include <math.h> #include <set> #include <vector> #define maxn 10005 #define INF 0x3f3f3f3f using namespace std; typedef long long ll; struct multi { int e; double c; }m1[maxn],m2[maxn]; int n,m,k,x,flag,t1,t2,p,root,cnt; double q; double a[maxn]; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d %lf",&p,&q); a[p]=q; if(i==1) root=p; } scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d %lf",&m1[i].e,&m1[i].c); cnt=0; while(root>=m1[1].e) { int te=root-m1[1].e; double tc=a[root]/m1[1].c; if(fabs(tc)>0.05) { m2[cnt].e=te; m2[cnt].c=tc; cnt++; for(int i=1;i<=n;i++) a[m1[i].e+te]-=m1[i].c*tc; } else root--; while(root>=m1[1].e&&fabs(a[root])<0.05) root--; } printf("%d",cnt); if(cnt==0) printf(" 0 0.0"); for(int i=0;i<cnt;i++) printf(" %d %.1lf",m2[i].e,m2[i].c); printf("\n"); cnt=0; while(root>=0) { if(fabs(a[root])>0.05) { m2[cnt].e=root; m2[cnt].c=a[root]; cnt++; } root--; } printf("%d",cnt); if(cnt==0) printf(" 0 0.0"); for(int i=0;i<cnt;i++) printf(" %d %.1lf",m2[i].e,m2[i].c); printf("\n"); return 0; }
标签:bsp pen span max include algo std lag play
原文地址:https://www.cnblogs.com/FTA-Macro/p/10525432.html