Codeforces——931B World Cup

晶晨刷机驱动WorldCup_Device麒麟刷机网下载.zip 立即下载

The last stage of Football World Cup is played using the play-off system.

There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third — with the fourth, the fifth — with the sixth, and so on. It is guaranteed that in each round there is even number of teams. The winner of each game advances to the next round, the loser is eliminated from the tournament, there are no draws. In the last round there is the only game with two remaining teams: the round is called the Final, the winner is called the champion, and the tournament is over.

Arkady wants his two favorite teams to play in the Final. Unfortunately, the team ids are already determined, and it may happen that it is impossible for teams to meet in the Final, because they are to meet in some earlier stage, if they are strong enough. Determine, in which round the teams with ids a and b can meet.

Input

The only line contains three integers n, a and b (2 ≤ n ≤ 256, 1 ≤ a, b ≤ n) — the total number of teams, and the ids of the teams that Arkady is interested in.

It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal.

Output

In the only line print "Final!" (without quotes), if teams a and b can meet in the Final.

Otherwise, print a single integer — the number of the round in which teams a and bcan meet. The round are enumerated from 1.

Examples

Input

4 1 2

Output

1

Input

8 2 6

Output

Final!

Input

8 7 5

Output

2

Note

In the first example teams 1 and 2 meet in the first round.

In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.

In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the first round.

 

模拟题,每次数据规模减小一半。只需要把相邻的两个组设为一样的数字,每次减少一半压缩数据。p的作用为遍历X节点压缩数据:

#include<stdio.h>
#define ll long long
using namespace std;
ll n,a,b,r,p,f,flag;
ll con[330];
int main()
{
    while(~scanf("%lld%lld%lld",&n,&a,&b))
    {
        r=p=f=flag=0;
        for(ll i=1;i<=n;i++)con[i]=i;
        while(1)
        {
            r++;
            for(ll i=2;i<=n;i+=2)
            {
                if((con[i-1]==a&&con[i]==b)||(con[i-1]==b&&con[i]==a))   //是否同时出现ab对阵
                {
                    flag=1;
                    break;
                }
                else if(con[i-1]==a||con[i]==a)con[++p]=a;   
                else if(con[i-1]==b||con[i]==b)con[++p]=b;             
      else con[++p]=con[i];   
            }
            if(flag==1)break;
            n/=2;
            p=0;
        }
        if(n==2)printf("Final!\n");
        else printf("%lld\n",r);
    }
    return 0;
}

 

WORLD CUP NULL 博文链接:https://rinoa1023.iteye.com/blog/683817 立即下载

相关推荐

Spring Boot 3.5.4 + LangChain4j实战:用Milvus搭建企业级RAG问答系统(附阿里百炼API配置)

本文详细介绍了如何利用Spring Boot 3.5.4、LangChain4j与Milvus构建企业级RAG问答系统。内容涵盖从架构设计、阿里百炼API安全配置、Milvus部署优化,到RAG检索、会话管理等核心实现,并提供了生产级API设计、监控集成及性能优化等实战经验,旨在帮助开发者打造高可用、可维护的Java AI应用。

weixin_29054399的博客 610

CodeForces - 931B World Cup(模拟)

World Cuptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe last stage of Football World Cup is played using the play-off system.There are n teams...

LP_Cong 1083

学习使用turtlebot2——ROS上安装turtlebot2

安装环境:    安装Ubuntu 14.04版本和ROS Indigo    参考:http://wiki.ros.org/turtlebot/Tutorials安装步骤    有两种安装方法,一种直接的安装命令,另外一种源码编译安装,区别在于:直接安装命令是安装在电脑默认路径/opt/ros/indigo/share里面不便于更改代码,因为默认路径下文件一般有访问权限,无法直接更改,需要使用s...

weixin_42670641的博客 2531

CodeForces - 931B World Cup (思维 模拟)

题目大意:      圆形球场有n个门,Allen想要进去看比赛。Allen采取以下方案进入球场:开始Allen站在第一个门,如果当前门前面有人Allen会花费单位时间走到下一个门,如果没人Allen从这个门就进去了。球场的每个门,每单位时间可以进去一个人。问Allen最终是从哪个门进入球场的? 题解:      如果是直接模拟的话,极限是数据是1e5个点,且值都是1e9,这样就算模拟是O...

hxxjxw的博客 491

Case-Based Reasoning用于RAG

在做大模型应用RAG的时候,会发现一种特殊的场景,就是基于之前的case进行回答,比如法律咨询、医疗诊断等等。这种情况的问答,需要有强有力的case支持才行,有了case支持,大模型回答会更加准确。CBR这个概念已经很久了,它是一种人工智能推理方法,它的基本思想是:遇到新问题时,先回忆相似的过去案例,再基于这些案例进行调整,得到新问题的解答。Retrieve(检索):在案例库中找到与当前问题最相似的案例。Reuse(复用):借鉴案例的解决方案来应对当前问题。

sinat_28694519的博客 938

OpenCLI入门:让任何网站变成你的命令行工具(超详细版)

最有用的工具,往往是最简单的。 opencli就是这样。 它不会帮你写代码,不会帮你做决策,但它能把200+个平台装进你的命令行。 让你用最简单的方式,获取最丰富的数据。

weixin_66295112的博客 2091

智能家居-斐讯N1安装篇

斐讯N1刷镜像小白教程 一、N1降级(固件版本为2.19的可以跳过这一步) 1、 首先你需要有一根双公头的 USB 数据线 其次你需要一个8G以上的质量较好的U盘 2、 开启 ADB 调试 N1 用 HDMI 连显示器,正常开机后用鼠标点击斐讯 N1 官方固件的那个版本号 4 次,出现 【ADB调试开启】的字样即可,如下图 3、选择2,N1降级 4、输入 .\fastboot.exe rebo...

weixin_46797666的博客 4251

WSL2 Ubuntu 22.04安装NVIDIA驱动避坑指南:从驱动版本选择到CUDA环境验证

本文详细介绍了在WSL2 Ubuntu 22.04中安装NVIDIA驱动和配置CUDA环境的完整流程,包括驱动版本选择、环境变量设置以及常见问题解决方案。通过本指南,用户可以避免常见的安装陷阱,确保GPU加速环境正确配置,适用于深度学习开发和CUDA编程。

weixin_28419039的博客 463

windows install libusb driver

本博客摘录于:https://blog.youkuaiyun.com/chengwenyang/article/details/51592633下载libusblibusb 可以从 http://libusb-win32.sourceforge.net 处下载,32位系统和64位系统均可以用,例如下载libusb-win32-bin-1.2.6.0。安装下载文件后解压缩,进入libusb-win32-bin-...

挖到尽头 4794

【AI面试】 Python 的装饰器

Python装饰器是一种高阶函数,用于在不修改原函数代码的情况下增强其功能。它通过@语法糖接收目标函数作为参数,并返回一个包含额外逻辑(如日志、缓存、权限验证等)的新函数。装饰器的核心价值在于代码复用和解耦,符合开闭原则,典型应用包括性能分析、权限控制等场景。例如,@timer_decorator可自动为函数添加耗时统计功能。本质上,@decorator等价于func = decorator(func),实际调用的是装饰器返回的包装函数。进阶技巧包括使用@functools.wraps保留原函数元信息。装饰

钱多多先森 184

Python爬虫:抓取交通工具班次数据(公交、地铁等时刻表)

然而,由于这些信息并不总是以开放的API形式提供,因此爬虫技术成为了获取和分析这些数据的有效途径。然而,由于很多公交公司没有公开API,通常我们通过抓取其网页中的时刻表数据来获取信息。通过这些步骤,您可以轻松抓取交通工具的班次信息,并进行进一步的数据分析,辅助交通规划和出行推荐系统的建设。在这篇文章中,我们将演示如何使用Python爬虫技术抓取公交、地铁等交通工具的班次和时刻表数据。我们可以将公交和地铁的数据合并,进行综合分析。我们可以进一步分析地铁班次的发车频率,甚至可以比较不同地铁线路的班次。

2201_76125261的博客 954

codeforces 931 B. World Cup

二叉树上的最近公共祖先问题

toby的博客 707

零基础学习CANoe Panel(5)——改变变量的值,控件图像也改变,这是怎么回事?

Panel 中控件的图像随着值变化,是怎么回事?

蚂蚁小兵 2145

World Cup CodeForces - 931B(暴力,最近公共祖先)

The last stage of Football World Cup is played using the play-off system. There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining te...

tomjobs的博客 495

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

codeforces 931B - World Cup 模拟

http://codeforces.com/contest/931/problem/B 足球联赛,有n支队伍,1和2打,3和4打,赢得晋级。现给出两支队伍的序号,若两支队伍足够强,他们能否会师决赛,若不能,会在第几轮见面? 在纸上试着模拟一下,比如1和2的winner下轮成为1,3和4的winner下轮成为2,以此类推。 #include &lt;bits/stdc++.h&gt; u...

西瓜不甜的博客 323

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

World Cup

<br />World Cup<br />Time Limit: 1000 ms     Case Time Limit: 1000 ms     Memory Limit: 65536 KB<br />Submit: 4     Accepted: 3 <br />Description<br /><br />A World Cup of association football is being held with teams from around the world. The standing is

kongming_acm的专栏 621

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Codeforces Round #468 B. World Cup

B. World CupThe last stage of Football World Cup is played using the play-off system.There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the r...

s540239976的博客 569

World Cup(CF#468-DIV1+2_B)

题目链接:http://codeforces.com/contest/931/problem/B题意:给你n,a,b  n是总的队伍数,a,b分别是两个人的所在的位置。问假设a,b都很强,请问他们在哪一个回合会碰面。如果最后一个回合就输出Final!分析:因为数据小,其实可以暴力求解,但是为什么不用一下官方题解的做法呢。其实可以不断除以2即可,考虑到如果奇数除以2会退一位所以要+1再除以2.只要他...

Z_sea的博客 378

Codeforces Round #468 C. Laboratory Work

C. Laboratory WorkAnya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.Kirill has alr...

s540239976的博客 277

wordcloud安装出错方法

直接输入pip install wordcloud,发现出错,说error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/然后要打开https://visualstudio.microsoft.com/visual-cpp-build-tools/,出现这.

mutouyuaichi的博客 1302

Codeforces Round #468 (Div. 2)B-World Cup(Java)

The last stage of Football World Cup is played using the play-off system. There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining t...

Cymbals的博客 668

codeforces 996B.World Cup(思维)

codeforces 996B. World Cup 题意: 开始Allen站在第一个门,如果当前门前面有人Allen会花费单位时间走到下一个门,如果没人Allen从这个门就进去了。球场的每个门,每单位时间可以进去一个人。问Allen最终是从哪个门进入球场的? 题解: 判断何时从这个门进,如果从第 i 个门进,第 i 个门有 k 个人,那么 x * n+ i > k ...

error311的博客 277

CodeForces ~ 996B ~ World Cup (思维)

题意 圆形球场有n个门,Allen想要进去看比赛。Allen采取以下方案进入球场:开始Allen站在第一个门,如果当前门前面有人Allen会花费单位时间走到下一个门,如果没人Allen从这个门就进去了。球场的每个门,每单位时间可以进去一个人。问Allen最终是从哪个门进入球场的? 思路 我们可以发现是有规律的。我们假设第iii个门有a个人,Allen第xxx圈可以从此进入,那么有:x∗n...

张松超的博客 721

codeforce 996-B. World Cup(模拟)

http://codeforces.com/problemset/problem/996/B 解题思路: 定义一个查找指针p初始化为1,循环节为n,然后找出最小数字,判断指针p,在这个数变成0的时候,是否不超过这个数的位置,如果不超过,则答案即为这个数所在的位置,否则对下一轮模拟一遍才能得出答案。 #include&lt;iostream&gt; #include&lt;algorithm&...

HJ 446

CodeForces 996B World Cup(两种方法,int可过long long超时的恶心例题)

  Description Allen wants to enter a fan zone that occupies a round square and has nn entrances. There already is a queue of aiai people in front of the ii-th entrance. Each entrance allows one per...

shezjoe的博客 587
上一篇: CodeForces——948C Producing Snow(优先队列)
下一篇: Largest prime factor (素数筛)
donCoder
博客等级 码龄9年 65粉丝 79原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值