HDOJ 3020 找规律
来源:互联网 发布:淘宝打包员招聘要求 编辑:程序博客网 时间:2024/06/06 03:23
FunnyXEN
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 156 Accepted Submission(s): 19
Problem Description
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.
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.
Input
Your program is to read from standard input.
There are multiple cases. For each case, one integer n (1 ≤ n ≤ 10^7) in a line.
There are multiple cases. For each case, one integer n (1 ≤ n ≤ 10^7) in a line.
Output
Output two integers with one space between them in one line per case.
Sample Input
24
Sample Output
2 14 1
Source
2009 Multi-University Training Contest 6 - Host by WHU
Recommend
gaojie | We have carefully selected several similar problems for you: 3021 3022 3023 3024 3030
分析:这题。。其实我看不出来背后有什么数学原理的,打表找规律。。
代码如下:
#include <cstdio>using namespace std;const int maxn = 25;int a[maxn],num[maxn];int n;void init(){ a[0] = 0; for (int i=1; i<20; i++) a[i] = 2*a[i-1]+1; num[1] = 3; for (int i=2; i<20; i++) num[i] = num[i-1]*3;}int main(){ init(); while (scanf("%d",&n)!=EOF){ if (n==1) {printf("1 0\n"); continue;} int tot = 0, x = 1; while (x<n) { tot++; x+=num[tot]; } printf("%d %d\n",n,a[tot]); } return 0;}
阅读全文
0 0
- HDOJ 3020 找规律
- hdoj 5344 找规律
- HDU/HDOJ 1284 找规律
- HDU/HDOJ 4203 找规律
- hdoj 1719 Friend(找规律)
- HDOJ 1418-抱歉【找规律】
- HDOJ 1005 找规律 周期性
- hdoj 4203 Doubloon Game(博弈+找规律)
- (精)hdoj(找规律)2374
- HDOJ 4203 Doubloon Game 博弈 找规律
- HDOJ 1005:取余,循环,找规律
- HDOJ 4731 - Minimum palindrome 找规律
- HDOJ 4350 —— 找规律
- hdoj 2018 母牛的故事 【找规律】
- hdoj 2277 Change the ball 【找规律】
- hdoj 1097 A hard puzzle 【找规律】
- hdoj 2160 母猪的故事(找规律)
- hdoj 2277 Change the ball 【找规律】
- python 实现冒泡排序
- 环信即时通讯2.x升级到3.x注意细节
- for循环语句计算8+88+888+...前10项之和(作业)
- 3秒钟不懂你砍我:RecyclerView下拉刷新和上拉加载更多
- php 安全
- HDOJ 3020 找规律
- maven搭建项目
- ZOJ3826(Hierarchical Notation)
- log4j使用方法
- CSS 多元素选择器
- Docker容器通过独立IP暴露给局域网的方法
- 康娜的幸运数字
- 【MySQL】经典数据库SQL语句编写练习题——SQL语句扫盲
- struts2教程&实例