1055. Combinations
1055. Combinations
Memory limit: 64 MB
Input
Output
Sample
| input | output |
|---|---|
5 3 |
2 |
Notes
#include <bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main(){
int m,n;
cin>>m>>n;
for(int i=1;i<=m;i++){
int num=i;
for(int j=2;j*j<=i&&num!=1;j++){
while(num%j==0){
num/=j;
mp[j]++;
} }
if(num!=1){
mp[num]++;
}
}
for(int i=1;i<=n;i++){
int num=i;
for(int j=2;j*j<=i&&num!=1;j++){
while(num%j==0){
num/=j;
mp[j]--;
} }
if(num!=1){
mp[num]--;
}
}
for(int i=1;i<=m-n;i++){
int num=i;
for(int j=2;j*j<=i&&num!=1;j++){
while(num%j==0){
num/=j;
mp[j]--;
} }
if(num!=1){
mp[num]--;
}
}
int ans=0;
for(auto t:mp){
if(t.second!=0){
ans++;
}
}
cout<<ans<<endl;
}
版权所有,参考请贴网址;{^__^}
1055. Combinations的更多相关文章
- Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- [LeetCode] Factor Combinations 因子组合
Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4. Write a func ...
- [LeetCode] Combinations 组合项
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- [LeetCode] Letter Combinations of a Phone Number 电话号码的字母组合
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- Leetcode 254. Factor Combinations
Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4. Write a func ...
- 17. Letter Combinations of a Phone Number
题目: Given a digit string, return all possible letter combinations that the number could represent. A ...
- LeetCode——Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- Combination Sum II Combinations
https://leetcode.com/problems/combination-sum-ii/ 题目跟前面几道题很类似,直接写代码: class Solution { public: vector ...
- No.017:Letter Combinations of a Phone Number
问题: Given a digit string, return all possible letter combinations that the number could represent.A ...
- Leetcode 77, Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
随机推荐
- 【c#】从外部复制文本、图片到我的软件中的解决方案(支持ppt,qq等)
原文地址 https://www.cnblogs.com/younShieh/p/17010572.html 如果本文对你有所帮助,不妨点个关注和推荐呀,这是对笔者最大的支持~ 我们先考虑 ...
- [cocos2d-x]关于Action
Action的分类 第一种:FiniteTimeAction类:有限时间的动作类 第二种:Follow类:节点跟随另一种节点的类 第三种:Speed类:节点执行速度类 第一种有限时间的动作类又分为瞬时 ...
- sikulix___自动化办公___重复性_机械性_的电脑操作___python脚本___Java运行环境下德jar包完成自动化测试相关___截图编程控制键盘鼠标
sikulix___自动化办公___重复性_机械性_的电脑操作___python脚本___Java运行环境下德jar包完成自动化测试相关___截图编程控制键盘鼠标 应用场景: 公司内的大佬更改了xml ...
- 大公司为什么禁止SpringBoot项目使用Tomcat?
本文已经收录到Github仓库,该仓库包含计算机基础.Java基础.多线程.JVM.数据库.Redis.Spring.Mybatis.SpringMVC.SpringBoot.分布式.微服务.设计模式 ...
- 【原创】项目六 Load Of The Root
实战流程 新创建文件夹,在这个文件夹里进行操作 nmap扫描下网段 根据nmap逐个排查,发现目标主机,但只有22端口 因此进一步扫描22端口的具体信息,没有扫出很有用的信息 发现靶场又提示一个用户, ...
- 字符编码,存储引擎及MySQL字段类型相关知识点
字符编码,存储引擎及MySQL字段类型相关知识点 一.字符编码 1.在终端输入\s,查看数据库的基本信息(当前用户,版本,编码,端口号) 2.默认的配置文件是my-default.ini 拷贝上述的文 ...
- 自定义接口-lambda使用前提
自定义接口 lambda使用前提 可推导即可省略 Lambda强调的是"做什么"而不是"怎么做",所以凡是可以根据上下文推导得知的信息,都可以省略.例如上例还可 ...
- Vue12 监视属性
1 简介 所谓监听就是对内置对象的状态或者属性变化进行监听并且做出反应的响应,监听属性,意思就是可以监视其他数据的变化 2 使用 使用watch配置项,在配置项里面写上要监视的属性,每次属性值的变化都 ...
- spring-in-action_day02
开发web应用 # 开发Spring web应用,最基本的需要构建以下组件: 1.pojo类(从数据库获取数据) 2.pringmvc控制器 3.视图模板(页面) ##第一步 构建pojo类 p ...
- P1_Day1.学习目标
目标 能够知道如何创建小程序项目 能够清楚小程序项目的基本组成结构 能够知道小程序页面由几个部分组成 能够知道小程序中常见的组件如何使用 能够知道小程序如何进行协同开发和发布 学习目录 小程序简介 第 ...