多校1 OO’s Sequence 1001
2015-07-21 20:33
363 查看
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 256 Accepted Submission(s): 94
[align=left]Problem Description[/align]
OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know
∑i=1n∑j=inf(i,j) mod (109+7).
[align=left]Input[/align]
There are multiple test cases. Please process till EOF.
In each test case:
First line: an integer n(n<=10^5) indicating the size of array
Second line:contain n numbers ai(0<ai<=10000)
[align=left]Output[/align]
For each tests: ouput a line contain a number ans.
[align=left]Sample Input[/align]
5
1 2 3 4 5
[align=left]Sample Output[/align]
23
[align=left]Source[/align]
2015 Multi-University Training Contest 1
[align=left]Recommend[/align]
We have carefully selected several similar problems for you: 5299 5298 5297 5296 5295
哈哈!
View Code
Total Submission(s): 256 Accepted Submission(s): 94
[align=left]Problem Description[/align]
OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know
∑i=1n∑j=inf(i,j) mod (109+7).
[align=left]Input[/align]
There are multiple test cases. Please process till EOF.
In each test case:
First line: an integer n(n<=10^5) indicating the size of array
Second line:contain n numbers ai(0<ai<=10000)
[align=left]Output[/align]
For each tests: ouput a line contain a number ans.
[align=left]Sample Input[/align]
5
1 2 3 4 5
[align=left]Sample Output[/align]
23
[align=left]Source[/align]
2015 Multi-University Training Contest 1
[align=left]Recommend[/align]
We have carefully selected several similar problems for you: 5299 5298 5297 5296 5295
哈哈!
#include <math.h> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; const int mod=1e9+7; int main() { int n,i,j,k; int str[100005],spfa[10005],l[100005],r[100005]; int s; while(scanf("%d",&n)!=EOF) { for(i=1;i<=n;i++) scanf("%d",&str[i]); for(i=1;i<=10000;i++) spfa[i]=0; for(i=1;i<=n;i++) l[i]=0,r[i]=n+1; for(i=1;i<=n;i++) { for(j=1;j<=sqrt(str[i]);j++) { if(str[i]%j==0) { if(spfa[j]>l[i]) l[i]=spfa[j]; if(spfa[str[i]/j]>l[i]) l[i]=spfa[str[i]/j]; } } spfa[str[i]]=i; } for(i=10000;i>=1;i--) spfa[i]=n+1; for(i=n;i>=1;i--) { for(j=1;j<=sqrt(str[i]);j++) { if(str[i]%j==0) { if(spfa[j]<r[i]) r[i]=spfa[j]; if(spfa[str[i]/j]<r[i]) r[i]=spfa[str[i]/j]; } } spfa[str[i]]=i; } s=0; for(i=1;i<=n;i++) { s=(s+(i-l[i])*(r[i]-i)%mod)%mod; } printf("%d\n",s); } return 0; }
View Code
相关文章推荐
- hdu 5288 OO’s Sequence
- hdu 5288 OO’s Sequence
- POJ 1019 Number Sequence 解读
- Brackets Sequence 括号DP
- 修改UIImage大小
- HDU 2818 - Building Block
- UIButton的一些设置
- 2015 Multi-University Training Contest 1 Hdu 5297 Y sequence
- hdu5288(2015多校1)OO’s Sequence
- iOS开发-UITableViewCell(UICollectionViewItem)需要两个手指点击或者长按才可以选中,解决办法
- 多校第一场 1001 hdu 5288 OO’s Sequence(枚举)
- HDU 5288 OO’s Sequence 区间个数
- 2015 Multi-University Training Contest 1 OO’s Sequence
- 多校7.21A——维护技巧——OO’s Sequence
- UITabBarItem初始化详解及UIImage渲染模式
- UILabel 垂直居中问题
- iOS UIView 快速修改 frame,避免累赘的书写方式
- hdu 5288OO’s Sequence
- Failed to instantiate the default view controller for UIMainStoryboardFile 'Main1' - perhaps the des
- uva 10746 Crime Wave - The Sequel (最小费最大流)