hdu 5211 Mutiple(枚举)

题意:

思路:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[10000+100];
int vis[10000+100];
int main()
{
    int n;
    int i,j,k;
    while(scanf("%d",&n)!=EOF)
    {
        int ans=0;
        memset(vis,0,sizeof(vis));
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            for(j=1;j<i;j++)
            {
                if(vis[j]==0&&a[i]%a[j]==0)
                {
                    ans+=i;
                    vis[j]=1;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

  

时间: 2024-10-11 15:19:33

hdu 5211 Mutiple(枚举)的相关文章

hdu 5211 Mutiple 数学

Mutiple Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5211 Description wld有一个序列a[1..n], 对于每个1≤i<n, 他希望你求出一个最小的j(以后用记号F(i)表示),满足i<j≤n, 使aj为ai的倍数(即aj mod ai=0),若不存在这样的j,那么此时令F(i) = 0保证1≤n≤10000,1≤ai≤10000 对于任意

HDU 5211 Mutiple 水题

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5211 题解: 1.筛法: 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 8 const int maxn=10000+10; 9 const i

hdu.5211.Mutiple(数学推导 &amp;&amp; 在logn的时间内求一个数的所有因子)

Mutiple Accepts: 476 Submissions: 1025 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描述 wld有一个序列a[1..n], 对于每个1≤i<n, 他希望你求出一个最小的j(以后用记号F(i)表示),满足i<j≤n, 使aj为ai的倍数(即aj mod ai=0),若不存在这样的j,那么此时令F(i) = 0 保证1≤n≤10000,1≤

HDU - 5210 - Delete &amp;&amp; 5211 - Mutiple (BestCoder Round #39)

题目传送:HDU - 5210 HDU - 5210 - Delete 思路:简单题 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> #include <queue> #include <stack> #include <vector> #include &l

HDU ACM 5211 Mutiple

分析:筛法的思想,首先记录每个值的坐标,在使用筛法. #include<iostream> using namespace std; int a[10005]; int f[10005]; int main() { int i,n,j,mx,ans,tmp; ios::sync_with_stdio(false); while(cin>>n) { mx=-1; memset(f,-1,sizeof(f)); for(i=1;i<=n;i++) { cin>>a[i

HDU 6103 Kirinriki 枚举长度 尺取法

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6103 题目描述: 定义两个相同长度的字符串的值为首尾开始字符串的ASCII相减, 求一个字符串中任取两个相同长度的不重叠的值不超过m的最大长度 解题思路: 求连续区间不超过某一个上限或者不低于某个下限的应该用尺取法 ,复杂度为O(n),  本题n是5000所以O(n^2)可行, 枚举前缀和后缀(通过枚举前缀, 再将字符串翻转枚举前缀进行), 再进行尺取 代码:  代码中有注释 #include <

Hdoj 5211 Mutiple 【水】

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 

HDU 4068 dfs枚举

SanguoSHA Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 944    Accepted Submission(s): 520 Problem Description Sanguosha has a singled version. Two players each select N heroes and start fight

HDU 5319 Painter(枚举)

Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 745    Accepted Submission(s): 345 Problem Description Mr. Hdu is an painter, as we all know, painters need ideas to innovate , one day,