标签:roc panel 3.2 vertica data- ica ace typedef padding
5 1 2 3 4 5
23
#include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<functional> #include<iostream> #include<cmath> #include<cctype> #include<ctime> #include<vector> using namespace std; #define For(i,n) for(int i=1;i<=n;i++) #define Fork(i,k,n) for(int i=k;i<=n;i++) #define Rep(i,n) for(int i=0;i<n;i++) #define ForD(i,n) for(int i=n;i;i--) #define RepD(i,n) for(int i=n;i>=0;i--) #define Forp(x) for(int p=pre[x];p;p=next[p]) #define Forpiter(x) for(int &p=iter[x];p;p=next[p]) #define Lson (x<<1) #define Rson ((x<<1)+1) #define MEM(a) memset(a,0,sizeof(a)); #define MEMI(a) memset(a,127,sizeof(a)); #define MEMi(a) memset(a,128,sizeof(a)); #define INF (2139062143) #define F (1000000007) #define MAXN (1000000+10) #define MAXn (1000000+10) typedef long long ll; ll mul(ll a,ll b){return (a*b)%F;} ll add(ll a,ll b){return (a+b)%F;} ll sub(ll a,ll b){return (a-b+llabs(a-b)/F*F+F)%F;} void upd(ll &a,ll b){a=(a%F+b%F)%F;} int a[MAXn],n; ll l[MAXN],r[MAXN]; ll al[MAXN],ar[MAXN]; int main() { // freopen("A.in","r",stdin); // freopen(".out","w",stdout); while(scanf("%d",&n)==1) { ll ans=0; For(i,n) scanf("%d",&a[i]); MEM(l) MEMI(r) For(i,n) { al[i]=0; int p=a[i]; for(int j=1;(ll)j*j<=(ll)p;j++) { if (p%j==0) al[i]=max(al[i],max(l[j],l[p/j])); } l[a[i]]=i; } ForD(i,n) { ar[i]=n+1; int p=a[i]; for(int j=1;(ll)j*j<=(ll)p;j++) { if (p%j==0) ar[i]=min(ar[i],min(r[j],r[p/j])); } r[a[i]]=i; } // For(i,n) cout<<al[i]<<' ';cout<<endl; // For(i,n) cout<<ar[i]<<' ';cout<<endl; // For(i,n) upd(ans,mul(i-al[i],ar[i]-i)); cout<<ans<<endl; } return 0; }
HDU 5288(OO’s Sequence-区间互质情况统计)
标签:roc panel 3.2 vertica data- ica ace typedef padding
原文地址:http://www.cnblogs.com/mthoutai/p/7191197.html