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 ...
随机推荐
- 开发中常用Fel的写法
直接看代码吧: package javademo; import java.util.HashMap;import java.util.Map; import com.greenpineyu.fel. ...
- 苹果发布【新开发语言】Swift
Swift is a multi-tenant, highly scalable and durable object storage system that was designed to stor ...
- win7显示方向旋转快捷键禁用及图形属性打开方法
方法/步骤 1 首先在桌面右键→打开[图形属性],如果没有,请看步骤2.如果有,直接进入步骤3 步骤阅读 2 为了美化桌面右键,往往会把桌面右键中的图形选项隐藏掉,此时,我们可以通过[控制面板]打 ...
- 单台centos7.3 虚拟机实现主从复制和哨兵集群
环境: centos7.3一台 部署图: 从服务器配置: slaveof 哨兵配置: port sentinel monitor m1 127.0.0.1 6379 2 sentinel monito ...
- poj1015 Jury Compromise【背包】
Jury Compromise Time Limit: 1000MS Memory Limit: 65536K Total Submissions:32355 Accepted:8722 ...
- AJAX Form Submit Framework 原生js post json
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest <!doctype ht ...
- Zipline Beginner Tutorial
Zipline Beginner Tutorial Basics Zipline is an open-source algorithmic trading simulator written in ...
- 【tensorflow】
运行计算图 session.run() https://blog.csdn.net/sinat_39372048/article/details/80868168 赋值 tf.assign() tf. ...
- Linux下的物理内存管理2-slab缓存的管理
2017-03-02 在Linux下的物理内存管理中,对SLAB机制大致做了介绍,对SLAB管理结构对象也做了介绍,但是对于小内存块的分配没有介绍,本节重点介绍下slab对小内存块的管理. 内核中使用 ...
- python pip命令技巧
确保本地开发环境,和线上一致性 1.导出当前解释器的模块pip3 freeze > requirements.txt 2.将这个文件requirements.txt,上传至服务器,在新的虚拟环境 ...