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 ...
随机推荐
- cmd窗口中java命令报错。错误:找不到或无法加载主类 java的jdk安装过程中踩过的坑
错误: 找不到或无法加载主类 HelloWorld 遇到这个问题时,我尝试过网上其他人的做法.有试过添加classpath,也有试过删除classpath.但是依然报错,这里javac可以编译通过,说 ...
- [OpenCV实战]39 在OpenCV中使用ArUco标记的增强现实
文章目录 1 什么是ArUco标记? 2 在OpenCV中生成ArUco标记 3 检测Aruco标记 4 增强现实应用 5 总结和代码 5.1 生成aruco标记 5.2 使用aruco增强现实 6 ...
- MongoDB - 分片简介
简介 什么是分片 高数据量和高吞吐量的数据库应用会对单机的性能造成较大压力,大的查询会将单机的 CPU 耗尽,大的数据量对单机的存储压力较大,最终会耗尽系统的内存压力转移到磁盘 IO 上. 为了解决这 ...
- [cocos2d-x]从源码角度思考convertToWorldSpace()与convertToWorldSpaceAR()坐标系的转换
convertToWorldSpace() 话不多说,先上源码,之后再慢慢讲解: (5和6图截图的时候重复了,这里就不弄出来了) 只要通过图1到图8中我写的注释进行分析(不懂的地方可以自己去翻一下co ...
- P5687 [CSP-S2019 江西] 网格图
题面 给定一个 \(n\times m\) 的网格图,行从 \(1\sim n\) 编号,列从 \(1\sim m\) 编号,每个点可用它所在的行编号 \(r\) 与所在的列编号 \(c\) 表示为 ...
- liunx系统安装Redis详细步骤
liunx系统安装Redis详细步骤 官网下载Redis安装包 使用工具将redis安装包拖入liunx系统 创建Redis存放目录 mkdir /usr/local/redis 解压到redis存放 ...
- ajax 用 get方法 验证登录
get-login-ajax.html --------------------------------------------- <body> <input type=" ...
- linux命令与公私钥
昨日内容回顾 etc目录 配置相关 /etc/profile 环境变量文件 /etc/motd 开机欢迎界面 usr目录 程序相关 四种安装软件的方式 1.yum安装 自动解决依赖性问题 2.rap安 ...
- django框架之drf:3、API执行流程、Response源码剖析、序列化器的简介和使用、反序列化的校验
Django框架之drf 目录 Django框架之drf 一.APIView执行流程 1.API执行流程总结(重点) 2.补充 二.Response源码剖析 1.Response类总结(重点) 三.序 ...
- 大三末java实习生一面凉经
在南京投了一些小公司,想找个实习,因为知道自己很菜,就收到了一家公司的面试. 面试一般在线上进行,我是在腾讯会议上进行的.面试官其实挺好的,一般不会为难你,因为他知道你是在校生不会懂那么多企业的技术. ...