XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem A. Arithmetic Derivative
题目:Problem A. Arithmetic Derivative
Input file: standard input
Output file: standard input
Time limit: 1 second
Memory limit: 256 mebibytes
Lets define an arithmetic derivative:
• if p = 1 then p0 = 0;
• if p is prime then p0 = 1;
• if p is not prime then n0 = (a · b)0 = a0 · b + a · b0.
For example, 60 = (2 · 3)0 = 20 · 3 + 2 · 30 = 5.
Given positive integers k and r, find all positive integers n such as n ≤ r and n0 = k · n.
Input
Input contains two integers k and r (1 ≤ k ≤ 30; 1 ≤ r ≤ 2 · 1018).
Output
If there are no such numbers, print 0. Otherwise in first line print m — number of positive integers n does
not exceeding r, for which n0 = k · n. Second line then must contain those m integers in ascending order.
Examples
standard input | standard input |
1 100 | 2 4 27 |
1 2 | 0 |
#include<iostream>
#include <vector>
#include <algorithm>
using namespace std; long long num[]={,,,,,,}; long long k,r,ans; vector<long long> v; void dfs(int x,long long nownum,long long r)
{
if(x>)
{
if(r)
return ;
if(nownum<=k)
{
ans++;
v.push_back(nownum);
}
return ;
}
long long nn=;
for(int i=;i<=r;i++)
{
if(i==)
dfs(x+,nownum,r);
else
{
if(k/nn<num[x])
break;
else
nn*=num[x];
if(k/nownum<nn)
break;
dfs(x+,nownum*nn,r-i);
}
}
return ;
} int main()
{
cin>>r>>k;
if(r==)
{
for(int i=;i<=;i++)
if(num[i]<=k)
ans++;
cout<<ans<<endl;
for(int i=;i<=ans;i++)
cout<<num[i]<<' ';
return ;
}
dfs(,,r);
cout<<ans<<endl;
sort(v.begin(),v.end());
for(int i=;i<ans;i++)
cout<<v[i]<<' ';
return ;
}
XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem A. Arithmetic Derivative的更多相关文章
- 【找规律】【DFS】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem A. Arithmetic Derivative
假设一个数有n个质因子a1,a2,..,an,那么n'=Σ(a1*a2*...*an)/ai. 打个表出来,发现一个数x,如果x'=Kx,那么x一定由K个“基础因子”组成. 这些基础因子是2^2,3^ ...
- 【二分】【字符串哈希】【二分图最大匹配】【最大流】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem I. Minimum Prefix
给你n个字符串,问你最小的长度的前缀,使得每个字符串任意循环滑动之后,这些前缀都两两不同. 二分答案mid之后,将每个字符串长度为mid的循环子串都哈希出来,相当于对每个字符串,找一个与其他字符串所选 ...
- XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem D. Clones and Treasures
题目:Problem D. Clones and TreasuresInput file: standard inputOutput file: standard outputTime limit: ...
- 【二分图】【并查集】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem L. Canonical duel
给你一个网格(n<=2000,m<=2000),有一些炸弹,你可以选择一个空的位置,再放一个炸弹并将其引爆,一个炸弹爆炸后,其所在行和列的所有炸弹都会爆炸,连锁反应. 问你所能引爆的最多炸 ...
- 【动态规划】【滚动数组】【bitset】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem J. Terminal
有两辆车,容量都为K,有n(10w)个人被划分成m(2k)组,依次上车,每个人上车花一秒.每一组的人都要上同一辆车,一辆车的等待时间是其停留时间*其载的人数,问最小的两辆车的总等待时间. 是f(i,j ...
- 【枚举】【最小表示法】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem F. Matrix Game
给你一个n*m的字符矩阵,将横向(或纵向)全部裂开,然后以任意顺序首尾相接,然后再从中间任意位置切开,问你能构成的字典序最大的字符串. 以横向切开为例,纵向类似. 将所有横排从大到小排序,枚举最后切开 ...
- 【推导】【构造】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem E. Space Tourists
给你n,K,问你要选出最少几个长度为2的K进制数,才能让所有的n位K进制数删除n-2个元素后,所剩余的长度为2的子序列至少有一个是你所选定的. 如果n>K,那么根据抽屉原理,对于所有n位K进制数 ...
- 【推导】【贪心】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem D. Clones and Treasures
给你一行房间,有的是隐身药水,有的是守卫,有的是金币. 你可以任选起点,向右走,每经过一个药水或金币就拿走,每经过一个守卫必须消耗1个药水,问你最多得几个金币. 药水看成左括号,守卫看成右括号, 就从 ...
- XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem F. Matrix Game
题目: Problem F. Matrix GameInput file: standard inputOutput file: standard inputTime limit: 1 secondM ...
随机推荐
- C语言的代码内存布局详解
一个程序本质上都是由 BSS 段.data段.text段三个组成的.这样的概念在当前的计算机程序设计中是很重要的一个基本概念,而且在嵌入式系统的设计中也非常重要,牵涉到嵌入式系统运行时的内存大小分配, ...
- jQuery插件手把手教会(一)
jQuery插件开发教程 ——让你的jQuery水平提升一个台阶 要说jQuery 最成功的地方,我认为是它的可扩展性吸引了众多开发者为其开发插件,从而建立起了一个生态系统.这好比大公司们争相做平台 ...
- 【ArcGIS for Android】经纬度坐标、地图投影坐标、屏幕坐标互相转换
SpatialReference mSR4326 = SpatialReference.create(4326); SpatialReference mSR3857 = SpatialReferenc ...
- Python tushare 初步了解
一.安装 1.Python 2.numpy 3.pandas 4.lxml 5.............. n.tushare 二.初步测试
- Visual Studio Code 配置 gulp
原本用的webstorm部署的gulp,后来由于太卡,打算换个编辑器,考虑了一番,之前用的是sublime,配置很是麻烦,最新听说饥人谷老师用的是vsCode,所以打算尝试一下这个编辑器,安装还是很方 ...
- 【黑金原创教程】【TimeQuest】【第二章】TimeQuest模型角色,网表概念,时序报告
声明:本文为黑金动力社区(http://www.heijin.org)原创教程,如需转载请注明出处,谢谢! 黑金动力社区2013年原创教程连载计划: http://www.cnblogs.com/al ...
- MyBatis 学习 - 注解
首先,POJO /** * @Title: Question.java * @Package com.test.model * @Description: TODO(POJO Question) * ...
- Navicat连接阿里云(centos7.3)的MySQL数据库遇到的问题及解决方法
注:本文涉及到的解决方案都是我遇到的问题的对应解决方案,不一定适用于每一个人,如果问题仍然存在,请继续百度查询其他解决方法 1. 首先是登录阿里云MySQL的一些必要信息(登录其他云主机的mysql ...
- Python全栈day10(基本数据类型及其常用方法)
一,数字 1,int 将字符串转化成数字 a = '123' b=int(a) b=123 2,以进制方式进行转换 num="a" >>> num = " ...
- 20165330 实验一 Java开发环境的熟悉
一.实验内容及步骤 使用JDK编译.运行简单的Java程序 使用命令 cd 20165330 进入到学号目录下 mkdir exp1新建文件夹 mkdir bin src建立bin src目录 vim ...