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. mysql修改sql_mode为宽松模式

    sql_mode ANSI TRADITIONAL STRICT_TRANS_TABLES sql_mode为空 最宽松的模式, 即使有错误既不会报错也不会有警告️ ANSI 宽松模式,对插入数据进行 ...

  2. fastjson反序列化漏洞原理及利用

    重要漏洞利用poc及版本 我是从github上的参考中直接copy的exp,这个类就是要注入的类 import java.lang.Runtime; import java.lang.Process; ...

  3. Oracle数据库基础操作语法

    转载自:https://www.cnblogs.com/fallen-seraph/p/10685997.html 一.登录Oracle数据库 首先运行Oracle数据库: 默认的有两个账号: 管理员 ...

  4. 阿里云OSS整合

    一.对象存储OSS 为了解决海量数据存储与弹性扩容(主要是静态文件的存储例如图片,语音,视频等),项目中我们通常采用云存储的解决方案- 阿里云OSS. 1.开通"对象存储OSS"服 ...

  5. 【高级排序算法】2、归并排序法的实现-Merge Sort

    简单记录 - bobo老师的玩转算法系列–玩转算法 -高级排序算法 Merge Sort 归并排序 Java实现归并排序 SortTestHelper 排序测试辅助类 package algo; im ...

  6. 【Linux】删除软连接被坑

    ------------------------------------------------------------------------------------------------- | ...

  7. 【老孟Flutter】源码分析系列之InheritedWidget

    老孟导读:这是2021年源码系列的第一篇文章,其实源码系列的文章不是特别受欢迎,一个原因是原理性的知识非常枯燥,我自己看源码的时候特别有感触,二是想把源码分析讲的通俗易懂非常困难,自己明白 和 让别人 ...

  8. 处理Promise.reject()

    一般处理Promise.reject()都是catch住错误,然后进行错误处理,一般都是再次发起请求或者直接打印. 直接打印的情况用console.error()就可以了,而再次发起请求呢? 最好是先 ...

  9. 2020年12月18号--21号 人工智能(深度学习DeepLearning)python、TensorFlow技术实战

    深度学习DeepLearning(Python)实战培训班 时间地点: 2020 年 12 月 18 日-2020 年 12 月 21日 (第一天报到 授课三天:提前环境部署 电脑测试) 一.培训方式 ...

  10. 牛逼!MySQL 8.0 中的索引可以隐藏了…

    MySQL 8.0 虽然发布很久了,但可能大家都停留在 5.7.x,甚至更老,其实 MySQL 8.0 新增了许多重磅新特性,比如栈长今天要介绍的 "隐藏索引" 或者 " ...