For any positive integer n, we define function F(n) and XEN(n).

For a collection S(n)={1,2,...,2n}, we select some numbers from it. For a selection, if each selected number could not be divided exactly by any other number in this selection, we will call the selection good selection. Further, we call a good selection best selection if the selection has more elements than any other good selection from S(n). We define F(n) the number of elements in the best selection from S(n). For example, n=2, F(n)=2. From the collection {1,2,3,4}, we can make good selection just like {2,3} or {3,4}, but we can't make any larger selection. So F(2) = 2.

Then we pay attention to XEN(n). For every S(n), there are always some numbers could not be selected to make up any best selection. For instance, when n=2, 1 is always could not be chosen. What's more, for every S(n), there is a number k which satisfies that all the number, from 0 to k, are always could not be chosen. Now we let XEN(n)=k:

n=2, F(n)=2, XEN(2)=1;
n=4, F(n)=4, XEN(4)=1.

You should write a program to calculate the value of F(n) and XEN(n) with a given number n.

InputYour program is to read from standard input.

There are multiple cases. For each case, one integer n (1 ≤ n ≤ 10^7) in a line.OutputOutput two integers with one space between them in one line per case.Sample Input

2
4

Sample Output

2 1
4 1

对于任意正整数n,定义函数F(n)和XEN(n)。

对于集合S(n)={1,2,…,2n},我们从中选择一些数字。对于一个选择,如果每个选择的数字不能被这个选择中的任何其他数字精确地除,我们将称之为好选择。此外,我们称一个好的选择为最佳选择,如果这个选择比从S(n)中的任何其他好的选择有更多的元素。我们定义F(n)为S(n)中最佳选择的元素个数。例如,n=2,F(n)=2。从集合{1,2,3,4}中,我们可以做出像{2,3}或{3,4}一样好的选择,但是我们不能做出任何更大的选择。所以F(2)=2。

然后我们注意XEN(n)。对于每一个S(n),总是有一些数字不能被选择来组成任何最佳选择。例如,当n=2时,总是不能选择1。而且,对于每一个s(n),都有一个数k,它满足从0到k的所有数都是不能选择的。现在我们让XEN(n)=k:

n=2,F(n)=2,XEN(2)=1;

n=4,F(n)=4,XEN(4)=1。

你应该写一个程序来计算F(n)和XEN(n)的值。

 1 #include <stdio.h>
2 #include <string.h>
3 #include <algorithm>
4 using namespace std;
5 int a[25],num[25];
6 int n;
7 void init()
8 {
9 a[0]=0;
10 for(int i=1;i<20;i++) a[i]=2*a[i-1]+1;
11 num[1]=3;
12 for(int i=2;i<20;i++) num[i]=3*num[i-1];
13 }
14 int main()
15 {
16 init();
17 while(~scanf("%d",&n)&&n)
18 {
19 if(n==1)
20 {
21 printf("1 0\n");
22 continue;
23 }
24 int m=0,x=1;
25 while(x<n)
26 {
27 m++;
28 x+=num[m];
29 }
30 printf("%d %d\n",n,a[m]);
31 }
32 }

FunnyXEN的更多相关文章

随机推荐

  1. Tomcat7,Tomcat8 的manager 配置

    1.打开文件:tomcat目录-->conf-->tomcat-users.xml  2.将以下代码替换原来的所有内容,不要犹豫,就是所有内容. <?xml version=&quo ...

  2. 【剑指 Offer】03.数组中重复的数字

    题目描述 找出数组中重复的数字. 在一个长度为 n 的数组 nums 里的所有数字都在 0-n-1 的范围内.数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次.请找出数组中 ...

  3. LeetCode150 逆波兰表达式求值

    根据逆波兰表示法,求表达式的值. 有效的运算符包括 +, -, *, / .每个运算对象可以是整数,也可以是另一个逆波兰表达式. 说明: 整数除法只保留整数部分. 给定逆波兰表达式总是有效的.换句话说 ...

  4. CopyOnWriteArrayList设计思路与源码分析

    CopyOnWriteArrayList实现了List接口,RandomAccess,Cloneable,Serializable接口. CopyOnWriteArrayList特性 1.线程安全,在 ...

  5. 简单解析一下 Mybatis 常用的几个配置

    目录 核心配置文件 环境配置(environments) 属性(properties) 类型别名(typeAliases) 映射器(mappers) Mybatis 参考:https://mybati ...

  6. 【Oracle】常见等待事件处理

    1.查看数据库中需要关注的等待事件: select sw.seq#,sw.sid||','||s.serial# sids,s.username,sw.event,sw.P1,sw.p2,sw.p3, ...

  7. 【linux】系统编程-6-POSIX标准下的信号量与互斥锁

    目录 前言 8. POSIX信号量 8.1 概念 8.2 POSIX无名信号量 8.3 POSIX有名信号量 8.4 POPSIX信号量与system V信号量的区别 9. POSIX互斥锁 9.1 ...

  8. SAP内表类型及其数据读取效率评估

    内表大概分3种: 1.标准表standard tables:如果不指定BINARY SEARCH附加选项,则默认为线性查找(linear search),既一条一条的查找. 2.排序表(sorted ...

  9. (数据科学学习手札104)Python+Dash快速web应用开发——回调交互篇(上)

    本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 这是我的系列教程Python+Dash快速web ...

  10. Hadoop2.7.7阿里云安装部署

    阿里云的网络环境不需要我们配置,如果是在自己电脑上的虚拟机,虚拟机的安装步骤可以百度.这里是单机版的安装(也有集群模式的介绍)使用Xshell连接阿里云主机,用命令将自己下载好的安装包上传到服务器 # ...