您当前的位置: 首页 > 

对方正在debug

暂无认证

  • 4浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Perfect Triples(思维/规律)

对方正在debug 发布时间:2020-04-23 11:03:29 ,浏览量:4

题目 题解&代码 题意:初始一个空数组 s s s,每次寻找不在数组中的3个不同的数,使得其异或和为0,并加入 s s s中。求 s s s第 n n n个数。 题解:规律发现所有数都会用上,且4进制相关,详见参考题解。

#include "iostream"
#include "stdio.h"
#include "string.h"
#include "algorithm"

using namespace std;

typedef long long ll;
const int N=1e6+5;
const ll mod=998244353;
const double eps=1e-5;


ll f[3][4]={{0,3,1,2},{},{0,2,3,1}};

void solve(ll x,int y)
{
    if(y==1)
    {
        printf("%lld\n",x);
        return;
    }
    ll ans=0,p=1;
    while(x)
    {
        ans=ans+f[y][x%4]*p;
        x>>=2;
        p_;
    while(_--)
    {
        cin>>n;
        ll j=1,a;
        while(j=n) a=j;
        else a=j+(n-j)/3;
        solve(a,n%3);
    }
    return 0;
}
关注
打赏
1664895754
查看更多评论
立即登录/注册

微信扫码登录

0.0387s