-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxor_factorisation.cpp
More file actions
41 lines (40 loc) · 857 Bytes
/
xor_factorisation.cpp
File metadata and controls
41 lines (40 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ll t;
cin>>t;
while(t--){
ll n,k;
cin>>n>>k;
vector<ll> v(k);
if(k%2==1){
for(ll i=0;i<k;i++){
v[i]=n;
}
}
else {
for(ll i=2;i<k;i++){
v[i]=n;
}
ll summ=0;
ll a,b;
ll fa,fb;
for( a=0; a<=n;a++){
b=n^a;
if(b<n ) {
summ=max(summ,a+b);
if(summ==a+b){
fa=a;
fb=b;
}
}
}
v[0]=fa;
v[1]=fb;
}
for(ll i=0;i<k;i++){
cout<<v[i]<<" ";
}
cout<<endl;
}}