We are the champions of the Eurocup! Well . . . almost. Actually, we lost in first round and didn’t win any match. But we were beaten by the real champions so, optimistically, we could be the second! Cup competitions are always unfair . . .
    Let’s consider a cup competition, that consists of N rounds where 2N teams take part. The winners of each round proceed to the next round. So in round 1 there are 2N teams, in round 2 there are 2N−1 teams, and so on. Teams are numbered 0, 1, 2, . . . , 2N − 1. The matches in each round are scheduled according to this order. Assume that, when two teams play, the one with the lowest number always wins. In conclusion, in round 1 the matches are: (0 vs. 1), (2 vs. 3), (4 vs.5), . . . ; in round 2: (0 vs. 2), (4 vs. 6), . . . The situation for N = 3 is shown in the picture below.

    A team, X, is better than all the teams it has beaten, and it is worse than all the teams it has lost with. Moreover, we can apply a sort of transitivity: X is better than all the team that are worse than the teams that are worse than X; and X is worse than the teams that are better than the teams that are better than X. For example, in the case of N = 3, team 7 is worse than 6, 4 and 0.
    When the competition is finished, all teams are given a ranking from 1 to 2N (different for each team, 1 for the winner, 2 for the subchampion, etc.). The ranking of team X is R(X). A valid ranking has the following property: if X is better than Y , then R(X) < R(Y ). Obviously, there are many possible valid rankings (because there are pairs of teams that we have no information between them). We define the optimistic classification of a team X as the smallest value of R(X) for any valid ranking R. Similarly, the pessimistic classification of X is the biggest value of R(X) for any valid ranking R.
    Given the number of rounds, N, and the number of a team, X, you have to compute the optimistic and pessimistic classification of X.
Input
The first line of the input contains an integer M, indicating the number of test cases. Each test case consists of two integers N and X. N is the total number of rounds in the competition (0 < N < 31), and X is the number of a team (0 ≤ X ≤ 2N − 1).
Output
For each test case, the output should consist of a single line with two integers: the optimistic and the pessimistic classification of the corresponding team.
Sample Input
4
3 1
4 10
2 2
4 15
Sample Output
2 8
3 15
2 3
5 16

问题链接:UVA10666 The Eurocup is Here!
问题简述:(略)
问题分析:数学模式或公式问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10666 The Eurocup is Here! */#include <bits/stdc++.h>using namespace std;int main()
{int t, n, x;scanf("%d", &t);while (t--) {scanf("%d%d", &n, &x);int tot = 1 << n;int tmp = x, cnt = 1;while(tmp) cnt += tmp&1, tmp >>= 1;tmp = (x == 0) ? (1 << n) : (x & -x);printf("%d %d\n", cnt, tot - tmp + 1);}return 0;
}

UVA10666 The Eurocup is Here!【数学模式】相关推荐

  1. LaTeX数学模式中的矩阵

    LaTeX数学模式中的矩阵 文章目录 一.矩阵环境 1.matrix环境 2.pmatrix环境 3.bmatrix环境 4.Bmatrix环境 5.vmatrix环境 6.Vmatrix环境 二.使 ...

  2. 通达信level2接口的数学模式

    通达信level2接口很多时候都是一些做量化交易的投资者使用的,量化交易这种投资方式,就是用过数学模式代替个人的主观判断,可以有效地降低由于情绪波动而造成的不必要失误,市场越是疯狂,这种交易模式就越是 ...

  3. Latex 数学符号显示为文本模式 数学模式转为文本模式

    用LaTeX写论文的时候遇到要将数学符号显示成文本格式,如'\left('编译后是'('但是我想让它编译后还是显示'\left(',只要在改为\verb| \left( |即可.\verb 命令被设计 ...

  4. 从联立方程式看机器学习的数学模式

    使用sympy解联立式程式 解下列联立式方程式. a+b=1 5a+b=2 from sympy import Symbol, solvea = Symbol('a') # 定义公式中使用的变量 b ...

  5. 不用数学也能讲清贝叶斯理论的马尔可夫链蒙特卡洛方法?这篇文章做到了

    作者 | Ben Shaver 翻译 | 刘畅 编辑 | Donna 大多数时候,贝叶斯统计在结果在最好的情况下是魔法,在最糟糕时是一种完全主观的废话.在用到贝叶斯方法的理论体系中,马尔可夫链蒙特卡洛 ...

  6. 一份数学小白也能读懂的「马尔可夫链蒙特卡洛方法」入门指南

    文章来源:机器之心 在众多经典的贝叶斯方法中,马尔可夫链蒙特卡洛(MCMC)由于包含大量数学知识,且计算量很大,而显得格外特别.本文反其道而行之,试图通过通俗易懂且不包含数学语言的方法,帮助读者对 M ...

  7. 引导直觉解决数学猜想难题,DeepMind登上《Nature》封面

    来源:机器之心 编辑:nhyilin 多年来,数学家们一直使用计算机来生成数据以帮助搜索数学模式,这种被称为实验数学的研究方法产生出许多重要的猜想,例如BSD猜想.虽然这种方法已经取得成功并且相当普遍 ...

  8. 为什么数学的用途这么大?

    来源:遇见数学 翻译:萧福坤译自 Science Digest, August 1985 原文: http://210.60.224.4/ct/content/1986/00050197/0008.h ...

  9. Matplotlib 中文用户指南 4.6 编写数学表达式

    编写数学表达式 原文:Writing mathematical expressions 译者:飞龙 协议:CC BY-NC-SA 4.0 你可以在任何 matplotlib 文本字符串中使用子 TeX ...

最新文章

  1. Numpy掩码数组masked arrays,这一篇就够了
  2. Effective C# 原则1:尽可能的使用属性(property),而不是数据成员(field)
  3. BeanShell增强的FOR循环
  4. 四十五、Gtihub+Hexo+icarus搭建自己的博客
  5. 腾讯里约——数字化中台的基石
  6. java jdbc is一个会话_java_JdbcUtilis_单实例
  7. 【git系列】提交新的PR-撤销git rebase
  8. 关于搜索引擎原理的详细解读
  9. 解决桌面单击右键反应慢的问题
  10. linux服务器6t硬盘分区,linux多块6T大硬盘分区挂载GPT分区
  11. 移动端手指滑动的距离
  12. 名帖104 赵孟頫 楷书《崑山州淮云院记》
  13. 皮特测评:蓝牙耳机哪个品牌最好?300元内最好的蓝牙耳机
  14. QQ、YY与webRTC回声消除效果对比分析与展望
  15. 安卓手机调试微信网页, 真机调试模式开启
  16. cousins什么意思_cousin是什么意思_cousin的翻译_音标_读音_用法_例句_爱词霸在线词典...
  17. mybatisMyBatis的嵌套查询-collection
  18. java数据库的量级_百度万亿量级数据库Tera架构应用、设计与实践全攻略
  19. C#编写数据分析软件(附源码)
  20. 软件工程师的薪资为何如此之高

热门文章

  1. vim搜索设置高亮:set hlsearch
  2. ArcGIS制图表达Representation实战篇3-控制点
  3. ArcMap自定义脚本工具制作
  4. 转载:python能用来做什么?
  5. Memcached windows 下安装与应用
  6. html5 数据懒加载图片,Jsoup+HtmlUnit获取懒加载数据
  7. cocos2d-x移植android,Cocos2d-x Xcode 移植到 Android stutio
  8. 1加6投屏_1加6投屏_6月的早餐,1杯牛奶加燕麦,营养健康又美味,饱腹感很强...
  9. python怎么读excelsheet_python怎么读写excel文件
  10. scala递归求斐波那契数列