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 ...
随机推荐
- flutter系列之:flutter中listview的高级用法
目录 简介 ListView的常规用法 创建不同类型的items 总结 简介 一般情况下,我们使用Listview的方式是构建要展示的item,然后将这些item传入ListView的构造函数即可,通 ...
- Ynoi 数据结构题选做
Ynoi 数据结构题选做 前言 我将成为数据结构之神!坚持 lxl 党的领导,紧随 nzhtl1477(女装灰太狼1477)的脚步.无论过去.现在还是未来,分块始终是实现 data structure ...
- 【rabbitmq】单独配置某一个消费者手动ack,其他消费者自动ack
前言:博主才疏学浅,此方案仅供参考,如有更优方案请大佬评论区告知,十分感谢✿✿ヽ(°▽°)ノ✿ 问题背景:同一个服务中存在多个不同业务的rabbitmq的消费者,其中一个推送业务的消费者需要加死信队列 ...
- 由char和byte的关系引申出去——总结一下java中的字符编码相关知识
由char和byte的关系引申出去--总结一下java中的字符编码相关知识 一.字符编码 手持两把锟斤拷,口中直呼烫烫烫 在文章伊始,先来复习一下计算机中关于编码的一些基础知识,着重理清以下几 ...
- 图文并茂strapi 4.5.5自定义搭建指南以及数据库字段名接口返回mapping分析
strapi是什么? 基于Nodejs的开源免费CMS框架 为什么选择它? 基于nodejs,100%JavaScript,上手迅速 可轻松创建功能强大且可自定义的API 可以使用任何喜欢的数据库 先 ...
- angular8实现前端携带cookie发送给后端+nodejs获取前端发送的cookie
1.前端测试代码angular8 // 测试代码 testCookie() { const url = 'http://10.11.11.11:3000/test/cookie' const para ...
- gRPC介绍(以Java为例)
1.简介 1.1 gRPC的起源 RPC是Remote Procedure Call的简称,中文叫远程过程调用.用于解决分布式系统中服务之间的调用问题.通俗地讲,就是开发者能够像调用本地方法一样调用远 ...
- 分布式协议与算法-Quorum NWR
1.强一致性与最终一致性 1.1强一致性 强一致性能保证写操作完成后,任何后续访问都能读到更新后的值:强一致性可以保证从库有与主库一致的数据.如果主库突然宕机,我们仍可以保证数据完整.但如果从库宕机或 ...
- 【随笔记】MFC 解决按下 ESC、Enter 键会自动退出的问题
网上大部分人的做法是通过拦截按键消息来屏蔽,实际正确的做法是: 1. 在对话框头文件重载 OnOK()(回车会触发) 和 OnCancel()(ESC会触发) 函数. // XXXXXXXDlg.h ...
- MRS_开发编译与设置相关问题汇总
解决问题如下: MRS开发编译时,如何修改工程优化等级 MRS进行工程编译时,如何配置FLASH.RAM显示占比 打印浮点类型 配置LD文件在工程中显示 使用sprintf打印 当重复多次调用相同函数 ...