题目描述
blablabla
样例
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int n=0,c=0,r=0,f=0;
int sum=0;
int i=0;
double c1=0.0,r1=0.0,f1=0.0;
int num[100];char animal[100];
cin>>n;
for(i=0;i<n;i++){
cin>>num[i]>>animal[i];
}
for(i=0;i<n;i++){
switch(animal[i]){
case 'C':c+=num[i];break;
case 'R':r+=num[i];break;
case 'F':f+=num[i];break;
}
}
sum=c+r+f;
c1=1.0*c/sum*100;
r1=1.0*r/sum*100;
f1=1.0*f/sum*100;
printf("Total: %d animals\nTotal coneys: %d\nTotal rats: %d\nTotal frogs: %d\nPercentage of coneys: %.2lf %\nPercentage of rats: %.2lf %\nPercentage of frogs: %.2lf %",sum,c,r,f,c1,r1,f1);
return 0;
}
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla