Hdoj 5211 Mutiple 【水】
来源:互联网 发布:苏州会所 知乎 编辑:程序博客网 时间:2024/05/16 05:24
Mutiple
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 65 Accepted Submission(s): 45
Problem Description
WLD likes playing with a sequence a[1..N] . One day he is playing with a sequence of N integers. For every index i, WLD wants to find the smallest index F(i) ( if exists ), that i<F(i)≤n , and aF(i) mod ai = 0. If there is no such an index F(i) , we set F(i) as 0.
Input
There are Multiple Cases.(At MOST 10 )
For each case:
The first line contains one integersN(1≤N≤10000) .
The second line containsN integers a1,a2,...,aN(1≤ai≤10000) ,denoting the sequence WLD plays with. You can assume that all ai is distinct.
For each case:
The first line contains one integers
The second line contains
Output
For each case:
Print one integer.It denotes the sum of allF(i) for all 1≤i<n
Print one integer.It denotes the sum of all
Sample Input
41 3 2 4
Sample Output
6HintF(1)=2F(2)=0F(3)=4F(4)=0
Source
BestCoder Round #39 ($)
代码:
#include <cstdio>#include <algorithm>#include <iostream>#include <cstring>#include <set>#define LL __int64using namespace std;const LL Mod = 10007;const LL M = 1e4+5;int s[M];int main(){ int n; while(scanf("%d", &n) == 1){ memset(s, 0, sizeof(s)); for(int i = 1; i <= n; ++ i){ scanf("%d", &s[i]); } int sum = 0; for(int i = 1; i < n; ++ i){ int Min = 1e7; for(int j = i+1; j <= n; ++ j){ if(s[j]%s[i] == 0&&Min > j){ Min = j; } } if(Min != 1e7) sum += Min; } printf("%d\n", sum); } return 0;}
0 0
- Hdoj 5211 Mutiple 【水】
- HDOJ-5211Mutiple(模拟)
- hdoj 5211 Mutiple 【数学】
- [5211]:Mutiple
- hdu 5211 Mutiple (乱搞)
- hdu 5211 Mutiple
- HDU ACM 5211 Mutiple
- hdu 5211 Mutiple
- HDU 5211Mutiple
- HDU 5211 Mutiple
- HDU 5211 Mutiple
- hdu 5211Mutiple
- bestcoder Mutiple
- hdu5211 Mutiple
- apache mutiple domains mutiple projects
- Chapter 11 Mutiple Documents and Mutiple Views
- HDU-5211-Mutiple(BestCoder+以后做题还是用c++吧.......)
- download to mutiple worksheets
- Redis管道(Pipelining)操作
- POJ3061 Subsequence (追逐法)
- Linux程序设计(Linux shell编程的例子:显示系统信息)
- Python画曲线图(论文,报告等常用)
- 用Python和Pygame写游戏-从入门到精通(9)
- Hdoj 5211 Mutiple 【水】
- WebViewJavascriptBridge源码解读
- Android工程中javax.annotation.Nullable找不到的替代方案
- Android 弹簧动画效果
- Hadoop安装前SSH无密码登录配置
- RMI简单教程
- Unable to find the ncurses libraries的解决办法
- poj--1961--KMP
- 视讯稳定对接出现的问题