Turn over to consider the impact, considering how few are multiples of him.
1#include <cstdio>2#include <iostream>3#include <cstring>4#include <cstdlib>5#include <cmath>6#include <queue>7#include <algorithm>8#include <vector>9 #defineM 1000009Ten #defineEPS 1e-10 One #definell Long Long A using namespacestd; - ll Read () - { the CharCh=GetChar (); -ll x=0, f=1; - for(;ch<'0'|| Ch>'9'; ch=GetChar ()) - if(ch=='-') +f=-1; - for(; ch>='0'&&ch<='9'; ch=GetChar ()) +x=x*Ten+ch-'0'; A returnx*F; at } - intn,sum[m],a[m],b[m],t,mx; - intMain () - { -n=read (); - for(intI=1; i<=n;i++) in { -a[i]=read (); tob[a[i]]++; +mx=Max (mx,a[i]); - } the for(intI=1; i<=mx;i++) * if(B[i]) $ {Panax Notoginseng for(intj=i;j<=mx;j+=i) -sum[j]+=B[i]; the } + for(intI=1; i<=n;i++) Aprintf"%d\n", sum[a[i]]-1); the return 0; +}
Bzoj 1607: [Usaco2008 dec]patting Heads Pat Bull Head