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. Docker-ce Centos8 笔记一:安装Docker-ce

    Docker是一个建设企业及数据中心服务仓库的进程,通过裸金属机和虚拟机承载的MAC.windows和linux系统提供本地和远程软件服务,涉及应用软件镜像.系统镜像.虚拟化仓库(虚拟机).它承载着灵 ...

  2. 【Java基础】数组和算法

    数组和算法 查找算法 线性查找 ... 二分查找 二分查找要求数据结构是有序的. package com.parzulpan.java.ch03; /** * @Author : parzulpan ...

  3. Docker Harbor 高可用 1.7.5版本(七)

    环境说明: node1 10.10.5.135 仓库 1 node2 10.10.5.136 仓库 2 node3 10.10.5.137 客户端 实验内容: Harbor 可以在两台主机之间相互同步 ...

  4. C++ 异常机制(上)

    目录 一.概念 二.异常的好处 三.基本语法 四.栈解旋 五.异常接口声明 六.异常对象的内存模型 七.异常对象的生命周期 一.概念 异常:存在于运行时的反常行为,这些行为超过了函数的正常的功能范围. ...

  5. [CPP] 智能指针

    介绍 C++ 的智能指针 (Smart Pointers) 相关 API. C++ 中的智能指针是为了解决内存泄漏.重复释放等问题而提出的,它基于 RAII (Resource Acquisition ...

  6. 【Linux】salt的cmd.script命令介绍

    salt是一个很棒的自动化运维工具之一,常用的有cmd.run,今天介绍的是cmd.script 其实一眼就能看出这个命令是执行脚本的命令 具体操作如下: 1.将/etc/salt/master中的 ...

  7. SAP下载文档为乱码

    通过事物WE60下载的文档为乱码,主要原因是编码格式的不匹配,通常默认的编码格式为ANSI编码,那么我们需要将源码的编码格式转换成UTF-8,这样问题可以解决了.   附:编码格式介绍 不同的国家和地 ...

  8. matlab图像处理程序大集合

    1.图像反转 MATLAB程序实现如下:I=imread('xian.bmp');J=double(I);J=-J+(256-1);                 %图像反转线性变换H=uint8( ...

  9. Ubuntu14.04系统安装

    1. 使用U盘或光盘进行引导进入系统安装向导. 2. 安装类型选择,选择中文(简体).然后点安装ubuntu. 3. 安装ubuntu电脑必须接入外网(外网的方式有自动获取或手动编辑IP地址). 网络 ...

  10. jmeter报Address already in use: connect

    jmeter报Address already in use: connect   用windows进行jmeter压测出现java.net.BindException: Address already ...