标签:sizeof span eof bsp rod mem main ble opened
和之前多项式求和类似,注意筛0和输出即可。水题~
#include <iostream> #include <cstring> #include <string> #include <sstream> #include <string> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #define maxn 1005 #define INF 0x3f3f3f3f #define EPS 1e-6 #define pi acos(-1.0) using namespace std; typedef long long ll; int n,m,x; double y; double a[2005],b[2005]; int c[maxn]; int main() { memset(b,0,sizeof(b)); cin>>n; for(int i=0;i<n;i++) { cin>>x>>y; c[i]=x; a[x]=y; } cin>>m; for(int i=0;i<m;i++) { cin>>x>>y; for(int j=0;j<n;j++) { double t1=y*a[c[j]]; int t2=x+c[j]; b[t2]+=t1; } } int p=0; for(int i=2005;i>=0;i--) { if(b[i]!=0) p++; } cout<<p; for(int i=2005;i>=0;i--) { if(b[i]!=0) printf(" %d %.1lf",i,b[i]); } cout<<endl; }
标签:sizeof span eof bsp rod mem main ble opened
原文地址:https://www.cnblogs.com/FTA-Macro/p/10057851.html