# SenseTime Ace Coder Challenge 暨 商汤在线编程挑战赛*(抽球游戏-fwt开立方)

Anthony 手中有 $n$$n$ 个依次标着整数 ${a}_{1}$$a_1$, ${a}_{2}$$a_2$, $\cdots$$\cdots$, ${a}_{n}$$a_n$ ($0\le {a}_{1}\le {a}_{2}\le \cdots \le {a}_{n}\le 63$$0 \leq a_1 \leq a_2 \leq \cdots \leq a_n \leq 63$) 的球，现在 Ben 会等概率随机抽出一个球，记录球上的数字并放回，重复该过程三次，最终三次记录下的数字的异或和就是 Ben 的得分。

### 输出格式

2
3 4
3 2 2 3
2 2 3 2
1 1 1 1
3 3
-1 -1 -1
-1 -1 -1
-1 -1 -1

Case #1: 22
Case #2: -7

fwt直接pow(1.0/3)就行。

#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
For(j,m-1) cout<<a[i][j]<<' ';\
cout<<a[i][m]<<endl; \
}
#define All(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
{
int x=0,f=1; char ch=getchar();
while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
bool fwt (ll a[] , int n ,bool on) {
for ( int d = 1 ; d < n ; d <<= 1 ) {
for ( int k = d << 1 , i = 0 ; i < n ; i += k ) {
for ( int j = 0 ; j < d ; ++ j ) {
ll x = a[i + j] , y = a[i + j + d] ;
if(on){
//xor
a[i + j] = ( x + y ) ;
a[i + j + d] = ( x - y );
}
else{
//xor
if((x&1)!=(y&1)) return 0;
a[i + j] = ( x + y ) /2 ;
a[i + j + d] = ( x - y) /2 ;
}
}
}
}
return 1;
}
#define MAXN (500)
ll a[MAXN];
int main()
{
//  freopen("C.in","r",stdin);
//  freopen(".out","w",stdout);
For(kcase,T) {

printf("Case #%d:",kcase);
if(tot%(n*n*n)){
puts(" -1");continue;
}
fwt(a,64,1);
bool fl=0;
Rep(i,64) {
double t=max(-a[i],a[i]);
t=pow(t,1.0/3);
t=floor(t+0.5);
ll c=t;
if(a[i]<0) c=-c;
if(c*c*c!=a[i]){
fl=1;
}else a[i]=c;
}
if(fl){
puts(" -1");continue;
}
fl=fwt(a,64,0);
tot=0;
Rep(i,64) tot+=a[i];
Rep(i,64) if(a[i]<0) fl=0;
if(tot!=n||!fl) {
puts(" -1");continue;
}
Rep(i,64) Rep(j,a[i]) printf(" %d",i);puts("");
}
return 0;
}


• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120