#include<iostream> #include<map> #include<cmath> #include<sstream> #include<vector> #include<string> using namespace std; struct single{     int p;     int q;     single(int i=0,int j=0)     {         p=i;         q=j;     } }; int main() {     int qsum=0;     int psum=0;     string qq;     string pp;     getline(cin,pp);     getline(cin,qq);     istringstream ssq(qq);     istringstream ssp(pp);     map<int,single> T;     string temp;     while(ssq>>temp)     {         int i=stoi(temp);         T[i].q++;         qsum++;     }     while(ssp>>temp)     {         int i=stoi(temp);         T[i].p++;         psum++;     }     double prob=0;     for(map<int,single>::iterator it=T.begin();it!=T.end();++it)     {         int p=(*it).second.p;         int q=(*it).second.q;         if(p==0)continue;         double pp=(double)p/(double)psum;         double qq=(double)q/(double)qsum;         double t=pp*log(pp/qq);         prob+=t;     }     printf("%.2f\n",prob);     system("pause");     return 0; } 哪个大佬帮我看看哪里有错啊?一直是0
点赞 2

相关推荐

12-11 14:24
门头沟学院 Java
牛客35720396...:不要用boss,全是骗
点赞 评论 收藏
分享
11-04 10:30
已编辑
门头沟学院 研发工程师
开心小狗🐶:“直接说答案”
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务