标签:Furlo 156 coins Codeforces Rublo output input Copy
E. Furlo and Rublo and Game
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Furlo and Rublo play a game. The table has n piles of coins lying on it, the i-th pile has ai coins. Furlo and Rublo move in turns, Furlo moves first. In one move you are allowed to:
- choose some pile, let's denote the current number of coins in it as x;
- choose some integer y (0 ≤ y < x; x1 / 4 ≤ y ≤ x1 / 2) and decrease the number of coins in this pile to y. In other words, after the described move the pile will have y coins left.
The player who can't make a move, loses.
Your task is to find out, who wins in the given game if both Furlo and Rublo play optimally well.
Input
The first line contains integer n (1 ≤ n ≤ 77777) — the number of piles. The next line contains n integers a1, a2, ..., an(1 ≤ ai ≤ 777777777777) — the sizes of piles. The numbers are separated by single spaces.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64dspecifier.
Output
If both players play optimally well and Furlo wins, print "Furlo", otherwise print "Rublo". Print the answers without the quotes.
Examples
input
Copy
1 1
output
Copy
Rublo
input
Copy
2 1 2
output
Copy
Rublo
input
Copy
10 1 2 3 4 5 6 7 8 9 10
output
Copy
Furlo
分析:首先枚举出前几项的SG函数值,然后通过尺取法算出后面的SG函数值。
[1,3]的SG为0,SG[4]的函数值为1,考虑左端点l=x^(1/4)和右端点r=x^(1/2),当且仅当r<4时sg才为1,所以算出sg为1的区间表示为[4,15],以此类推。由于区间都是平方关系,所以直接手算就可以了。
#include "bits/stdc++.h"
using namespace std;
int sg(long long x)
{
if(x<=3)return 0;
if(x<=15)return 1;
if(x<=81)return 2;
if(x<=6723)return 0;
if(x<=50625)return 3;
if(x<=2562991875LL)return 1;
else return 2;
}
int main() {
int n;
cin >> n;
int ans=0;
for (int i = 1; i <= n; ++i) {
long long x;cin>>x;
ans^=sg(x);
}
if(ans)puts("Furlo");
else puts("Rublo");
}
标签:Furlo,156,coins,Codeforces,Rublo,output,input,Copy 来源: https://blog.csdn.net/qq_42671946/article/details/89490881
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。