题目描述
blablabla
样例
#include <iostream>
using namespace std;
int main()
{
int n;
int a;
char t;
int sum=0,sum1=0,sum2=0,sum3=0;
double s1,s2,s3;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a>>t;
if(t=='C')
sum1+=a;
else if(t=='R')
sum2+=a;
else
sum3+=a;
sum+=a;
}
s1=(double)sum1/(double)sum*100;
s2=(double)sum2/(double)sum*100;
s3=(double)sum3/(double)sum*100;
cout<<"Total: "<<sum<<" animals"<<endl;
cout<<"Total coneys: "<<sum1<<endl;
cout<<"Total rats: "<<sum2<<endl;
cout<<"Total frogs: "<<sum3<<endl;
printf("Percentage of coneys: %.2lf %\n",s1);
printf("Percentage of rats: %.2lf %\n",s2);
printf("Percentage of frogs: %.2lf %\n",s3);
return 0;
}
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla