【BZOJ】1607: [Usaco2008 Dec]Patting Heads 輕拍牛頭
阿新 • • 發佈:2017-07-18
span urn isp view splay none for gif class
【算法】模擬
#include<cstdio> #include<algorithm> using namespace std; const int maxn=100010,maxm=1000010; int a[maxn],A[maxm],n; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); A[a[i]]++; } for(int i=1;i<=n;i++) {View Codeint ans=0; for(int j=1;j*j<=a[i];j++)if(a[i]%j==0) { int k=a[i]/j; // printf("j=%d k=%d\n",j,k); ans+=A[j]; if(j!=k)ans+=A[k]; } printf("%d\n",ans-1); } return 0; }
【BZOJ】1607: [Usaco2008 Dec]Patting Heads 輕拍牛頭