mnsday2t1
枚举每个数的因子,然后该因子数量+1,最后扫描一遍,如果该因子数量小于等于m且该因子在1-n之间就输出
复杂度:枚举因子:O(n^1/2*m) 输出答案 : 大概是O(m*?) 一个不知道的数字
#include<iostream>
#include<cstdio>
#include<map>
#define pt map<int,int>::iterator
using namespace std;
map<int,int>mp;
map<int,int>cnt;
int a[],tot[];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=;i<=m;i++) scanf("%d",&a[i]);
for(int i=;i<=m;i++)
{
mp.clear();
for(int j=;j*j<=a[i];j++)
if(a[i]%j==) mp[j]=mp[a[i]/j]=;
for(pt it=mp.begin();it!=mp.end();it++)
cnt[it->first]++;
}
tot[]=n;
for(pt it=cnt.begin();it!=cnt.end();it++)
{
if(it->first<=n) tot[]--;
if(it->second<=m&&it->first<=n) tot[it->second]++;
}
for(int i=;i<=m;i++) printf("%d\n",tot[i]);
return ;
}
mnsday2t1的更多相关文章
随机推荐
- 编写 Unity Editor 插件
Editor Style Viewer 在开发过程中,我喜欢编写一些辅助的Editor插件,方便在游戏开发过程进行调试. 下面是摘自Asset Store的一个查看Unity 默认GUI样式的小工具 ...
- SQL Server 索引设计指南
https://msdn.microsoft.com/zh-cn/library/jj835095(v=sql.120).aspx#Nonclustered
- 向tiny6410移植tslib(tslib-1.4)
环境:RedHat 已安装交叉编译器 tslib版本:1.4 首先在redhat文件系统的/usr/local/tslib 创建目录 拷贝源代码tslib-1.4.tar.gz到/usr/local/ ...
- .Net程序员学习Linux最简单的方法
有很多关于Linux的书籍,博客.大多数都会比较“粗暴“的将一大堆的命令塞给读者,从而使很多.NET程序员望而却步.未入其门就路过了. 所以我设想用一种更为平滑的学习方式, 就是在学习命令时,先用纯语 ...
- scrapy系统学习(1)--概要
本文操作环境:ubuntu14.04 一.安装Scrapy/Mysql/MySQLdb 参照官网教程安装Scrapy #sudo apt-key adv --keyserver hkp://keyse ...
- redis-cache中的callback
这个是mybatis/redis-cache中关键类 RedisCache 的源码 /** * Copyright 2015 the original author or authors. * * ...
- Smoothing in fMRI analysis (FAQ)
Source: http://mindhive.mit.edu/node/112 1. What is smoothing? "Smoothing" is generally us ...
- codevs2010 求后序遍历
难度等级:白银 2010 求后序遍历 题目描述 Description 输入一棵二叉树的先序和中序遍历序列,输出其后序遍历序列. 输入描述 Input Description 共两行,第一行一个字符串 ...
- Python2.6-原理之类和oop(上)
来自<python学习手册第四版>第六部分 一.oop:宏伟蓝图(26章) 在这之前的部分中,经常会使用"对象"这个词,其实,到目前为止都是以对象为基础的,在脚本中传递 ...
- 前端备忘录 — IE 的条件注释
CSS hack 由于不同厂商的浏览器,比如 Internet Explorer,Safari,Mozilla Firefox, Chrome 等,或者是同一厂商的浏览器的不同版本,如 IE6 和 I ...