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. python学习笔记 | PyCharm创建文件时自动添加头文件

    File Settings Editor File and Code Templates Python Script 然后在右边的框中写入信息就可以啦: # -*- coding: utf-8 -*- ...

  2. 通过JS逆向ProtoBuf 反反爬思路分享

    前言 本文意在记录,在爬虫过程中,我首次遇到Protobuf时的一系列问题和解决问题的思路. 文章编写遵循当时工作的思路,优点:非常详细,缺点:文字冗长,描述不准确 protobuf用在前后端传输,在 ...

  3. kubernets之服务重定向

    一  服务的强大功能之处的其他表现 前面介绍的所有有关服务的说明,都是将集群内部的pod应用暴露出来提供外部客户端或者内部的客户端进行访问,但是服务的强大之处远远不止于此 服务甚至可以将集群外部的应用 ...

  4. Oracle备份审计表SYS.AUD$和SYS.FGA_LOG$

    ORACLE的审计表不可以使用expdp和impdp导出和导入,如果使用,会报如下错误: 需要使用exp和imp进行导出和导出 导出语句: exp " '/ as sysdba' " ...

  5. 误删除SAP ECC中的profile文件

    环境:ECC6.0 EHP4  FOR ORACLE ON WINDWS X64下 今天在RZ10配置系统参数文件的时候,不小心错删除了instance profile文件,这下惨了,这是操作系统层级 ...

  6. MYSQL基础知识的复习2

    1.修改表中的数据 update 表名 set 要修改的字段 where 条件;-- 如果修改多个字段那么字段和字段之间用逗号隔开 2.查询(很重要) 1.查询表中部分字段: select 字段名,字 ...

  7. js中常用追加元素的几种方法

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. 关于java并发场景下,HttpServletRequst中session丢失问题

    使用场景: 在list数据进来之后使用安全数组    Lists.newCopyOnWriteArrayList() 进行了   parallelStream  并行处理,在接口中进行了登录者信息接口 ...

  9. Maven + springboot + mybatis 构建多模块工程

    废话不说先上最终效果:创建一个空项目,再创建一个父项目用来管理各模块并维护各模块关系,简要说明如下: parent模块:主要用来管理以下各模块,和各模块涉及的jar包版本和boot项目入口级的的依赖管 ...

  10. 关于springboot2.X使用外部tomcat服务器进行部署的操作详细步骤

    1.修改pom.xml文件(4个地方) ①<packaging>war</packaging>将其中的jar该为war ②<dependency> <grou ...