GYM 101606 J.Just A Minim(水~)

Description

编码和时长的对应关系如下表

img

给出 n 个编码,问总时长

Input

第一行一整数 n 表示编码个数,之后输入 n 个编码 ( 1 n 2000 )

Output

输出编码代表的总时长

Sample Input

4
1 1 1 0

Sample Output

5

Solution

简单题,统计每个编码出现次数乘上所代表时长累加即为答案

Code

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=20;
int n,num[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int a;
        scanf("%d",&a);
        num[a]++;
    }
    double ans=2*num[0]+num[1]+num[2]/2.0+num[4]/4.0+num[8]/8.0+num[16]/16.0;
    printf("%.9f\n",ans);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/v5zsq/article/details/80449925