hdu 5211 Mutiple 数学
Mutiple
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5211
Description
保证1≤n≤10000,1≤ai≤10000 对于任意 1≤i≤n, 且对于任意1≤i,j≤n(i!=j),满足ai != aj
Input
多组数据(最多100组)
对于每组数据:
第一行:一个数n表示数的个数
接下来一行:n个数,依次为a1,a2,…,an
接下来一行:一个数k表示操作数
Output
对于每组数据:
输出最多剩下的不同的数的个数
Sample Input
4
1 3 1 2
Sample Output
HINT
F(1)=2
F(2)=0
F(3)=4
F(4)=0
题意
题解:
对于每一个数,我们都直接枚举倍数就好了,直接倒着做!
代码:
- //qscqesze
- #include <cstdio>
- #include <cmath>
- #include <cstring>
- #include <ctime>
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <sstream>
- #include <queue>
- #include <typeinfo>
- #include <fstream>
- #include <map>
- #include <stack>
- typedef long long ll;
- using namespace std;
- //freopen("D.in","r",stdin);
- //freopen("D.out","w",stdout);
- #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
- #define maxn 200001
- #define mod 10007
- #define eps 1e-9
- int Num;
- char CH[];
- //const int inf=0x7fffffff; //нчоч╢С
- const int inf=0x3f3f3f3f;
- /*
- inline void P(int x)
- {
- Num=0;if(!x){putchar('0');puts("");return;}
- while(x>0)CH[++Num]=x%10,x/=10;
- while(Num)putchar(CH[Num--]+48);
- puts("");
- }
- */
- //**************************************************************************************
- inline ll read()
- {
- int x=,f=;char ch=getchar();
- while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
- while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
- return x*f;
- }
- inline void P(int x)
- {
- Num=;if(!x){putchar('');puts("");return;}
- while(x>)CH[++Num]=x%,x/=;
- while(Num)putchar(CH[Num--]+);
- puts("");
- }
- int a[],mp[];
- int main()
- {
- int n;
- while(scanf("%d",&n)!=EOF)
- {
- ll ans=;
- for(int i=;i<=n;i++)
- a[i]=read();
- for(int i=;i<=;i++)
- mp[i]=n+;
- for(int i=n;i;i--)
- {
- int mi=n+;
- for(int j=a[i];j<;j+=a[i])
- mi=min(mi,mp[j]);
- if(mi<=n)
- ans+=mi;
- mp[a[i]]=i;
- }
- printf("%lld\n",ans);
- }
- }
hdu 5211 Mutiple 数学的更多相关文章
- hdu.5211.Mutiple(数学推导 && 在logn的时间内求一个数的所有因子)
Mutiple Accepts: 476 Submissions: 1025 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 6553 ...
- HDU 5211 Mutiple 水题
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5211 题解: 1.筛法: #include<iostream> #include< ...
- HDU 5673 Robot 数学
Robot 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5673 Description There is a robot on the origi ...
- HDU 5914 Triangle 数学找规律
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...
- HDU 2493 Timer 数学(二分+积分)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2493 题意:给你一个圆锥,水平放置,圆锥中心轴与地面平行,将圆锥装满水,在圆锥某一表面开一个小洞,流出来 ...
- HDU 1568 Fibonacci 数学= = 开篇
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1568 分析:一道数学题 找出斐波那契数列的通项公式,再利用对数的性质就可得到前几位的数 斐波那契通项公 ...
- hdu 4602 Partition 数学(组合-隔板法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4602 我们可以特判出n<= k的情况. 对于1<= k<n,我们可以等效为n个点排成 ...
- HDU 1030 Delta-wave 数学题解
给出一个数字塔,然后求沿着数字之间的边走,给出两个数字,问其路径最短的长度是多少. 看似一条搜索题目,只是有一定做题经验的人都知道,这个不是搜索题,直接搜索肯定超时. 这个是依据规律计算的数学题目. ...
- HDU 5698 瞬间移动 数学
瞬间移动 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5698 Description 有一个无限大的矩形,初始时你在左上角(即第一行第一列),每次 ...
随机推荐
- 72.Edit Distance---dp
题目链接:https://leetcode.com/problems/edit-distance/description/ 题目大意:找出两个字符串之间的编辑距离(每次变化都只消耗一步). 法一(借鉴 ...
- STL中heap相关函数
heap并不是属于STL中的containers,而是在<algorithm>下提供了相关的函数 make_heap,sort_heap,pop_heap,push_heap 函数的说明: ...
- 模板为webpack的目录结构
目录结构 | -- build // 项目构建(webpack)相关代码 | |-- build.js // 生产环境构建代码 | |-- check-version.js // 检查node.npm ...
- Spring Boot学习——单元测试
本随笔记录使用Spring Boot进行单元测试,主要是Service和API(Controller)进行单元测试. 一.Service单元测试 选择要测试的service类的方法,使用idea自动创 ...
- shell中的变量与eval(转)
原文链接:http://www.361way.com/shell-eval-variable/4957.html shell 中经常会用到变量的嵌套的情况.比如,单个或多个变量的值作为变量名,再对该变 ...
- static变量和final变量
1.static变量 按照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:另一种是没有被static修饰的变量,叫实例变量.两者的区别是: 对于静态变量在内 ...
- LGPL 与GPL的区别
GPL(GNU General Public License) 我们很熟悉的Linux就是采用了GPL.GPL协议和BSD, Apache Licence等鼓励代码重用的许可很不一样.GPL的出发点是 ...
- 关于真多核和加多核&线程由哪几部分组成
网上查的资料小结,没有考证. 真多核是指一个cpu多个核心,即多个内核. 假多核是指多个cpu捆绑形成的分布式计算,ARM针对服务器市场推出的处理器为多个cpu的 真多核的应用奔腾和因特尔 双核芯cp ...
- 面试题12:打印1到最大的n位数(大数问题)
面试题是关于n位整数并且没有限定n的取值范围,或者是输入任意大小的整数,那么这个题目就很可能需要考虑大数问题.字符串是一个简单的.有效的表示大数的方法 这题比较难,用递归表达全排列,数字每一位都可能是 ...
- 修改MySQL事件
MySQL允许您更改现有事件的各种属性. 要更改现有事件,请使用ALTER EVENT语句,如下所示: ALTER EVENT event_name ON SCHEDULE schedule ON C ...