mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
a4744a8c1c
5200-5299
28 lines
664 B
C++
28 lines
664 B
C++
#include<iostream>
|
|
#include<cstring>
|
|
#include<cstdio>
|
|
#include<cmath>
|
|
using namespace std;
|
|
#define MAXN 10005
|
|
int num[MAXN],n,f[MAXN];
|
|
int main()
|
|
{
|
|
while(scanf("%d",&n) != EOF)
|
|
{
|
|
int ans = 0;
|
|
memset(f,0,sizeof(f));
|
|
for(int i = 0;i < n;i++)
|
|
scanf("%d",&num[i]);
|
|
for(int i = n - 1;i >= 0;i--)
|
|
{
|
|
ans += f[num[i]];
|
|
int q = sqrt(num[i] + 1) + 1;
|
|
for(int j = 1;j <= q && j <= num[i];j++)
|
|
if(num[i] % j == 0)
|
|
f[j] = i + 1,
|
|
f[num[i] / j] = i + 1;
|
|
}
|
|
printf("%d\n",ans);
|
|
}
|
|
}
|