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 ...
随机推荐
- 希腊字母表及latex代码
希腊字母表及latex代码 字母大写 字母小写 英文名称 latex大写代码 latex小写代码 \(\Alpha\) \(\alpha\) alpha \Alpha \alpha \(\Beta\) ...
- 【转载】七个人生工具,终生受益 | SWOT、PDCA、6W2H、SMART、WBS、时间管理、二八原则
人类历史原本就是一部追求自身平衡的奋斗史,本文介绍七个人生工具:SWOT.PDCA.6W2H.SMART.WBS.时间管理.二八原则 . 1.SWOT分析法 Strengths:优势 Weakness ...
- 为 ASPNETCORE 7 项目添加 Serilog
本文将介绍如何为 ASP.NET Core 项目添加 Serilog. 添加 Serilog 首先,我们需要在项目中添加 Serilog 的 NuGet 包. dotnet add package S ...
- SQLSERVER 居然也能调 C# 代码 ?
一:背景 1. 讲故事 前些天看到一个奇怪的 Function 函数,调用的是 C# 链接库中的一个 UserLogin 方法,参考代码如下: CREATE FUNCTION dbo.clr_User ...
- [深度学习] caffe分类模型训练、结果可视化、部署及量化笔记
本文为本人caffe分类网络训练.结果可视化.部署及量化具体过程的心得笔记.caffe目前官方已经停止支持了,但是caffe是目前工业落地最常用的深度学习框架,用的人挺多.其实主要怕自己忘了,弄个备份 ...
- [生命科学] snapgene 构建载体方法分享
snapgene 构建载体方法分享 文章目录 snapgene 构建载体方法分享 1. Snapgene 构建载体-酶切位点法 2. 载体构建--同源重组法 3. 总结 1. Snapgene 构建载 ...
- session取不到值
今天鼓捣项目时出现了一个问题 项目重启后,设置session值后,第一次请求经过过滤器时 session取不到值,导致被拦截 经过半天的研究,终于...我请教了别人 把代码给了朋友,在朋友一段时间的琢 ...
- 高并发解决方案orleans实践
开具一张图,展开来聊天.有从单个服务.consul集群和orleans来展开高并发测试一个小小数据库并发实例. 首先介绍下场景,创建一个order,同时去product表里面减掉一个库存.很简单的业务 ...
- python3进行3des的加密解密
#秘钥长度正常24位,16位补齐第一个八位 import pyDes import base64 print('=======key1=======') keys='1234567890123456' ...
- Ubuntu snap 下载慢
解决方法 sudo apt-get install snapd sudo snap install snap-store sudo snap install snap-store-proxy sudo ...