Bestcoder 2 题目

点击量:9

#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <bitset>
using namespace std;
// 大数,内存处理
#define INF 0x3f3f3f3f
#define ll long long int
#define MEM(a) memset(a, 0, sizeof(a))
#define MEMM(a) memset(b, -1, sizeof(b))
#define DEB(x, n) cout << (x) << " " << (n) << endl
const double PI = acos(-1.0);
#define CR printf("\n")
// 调试用
    template <class Type>
void debug(Type a[], int len)
{
    for(int i = 0; i < len ; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}
int main()
{
#ifdef DEBUG
    // freopen("input", "r", stdin);       //从input文件中读入
    // freopen("output", "w", stdout);     //输出到output文件
#endif
    int n;
    int record[10010];
    int a[10010];
    while(scanf("%d", &n) != EOF)
    {
        memset(record, 0, sizeof(record));
        for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
        for(int i = 1; i <= n;i ++)
            for(int j = i+1; j <= n; j++)
            {
                if(a[j] % a[i] == 0)
                {
                    record[i] = j;
                    break;
                }
            }
        // debug(record, n+1);
        ll res = 0;
        for(int i = 1; i <= n; i++)
            res += record[i];
        printf("%lld\n", res);
    }
    return 0;
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注