//#include "Annalib.h"
#include <bits/stdc++.h>
#define L long long
using namespace std;
void Set(int,int);
int a[150];
void Anna(int N,L X,int K,int P[]){
int i;
L bit=1;
for(i=0;i<N;i++)
{
a[i]=0;
}
for(i=0;i<K;i++)
{
a[P[i]]=-1;
}
for(i=0;i<N;i+=3)
{
//printf("%lld\n",i);
if(X<bit) break;
L sum=a[i]+a[i+1]+a[i+2];
if(sum<=-2) continue;
if(sum==0)
{
switch(X/bit%4){
case 0:
a[i]=a[i+1]=a[i+2]=1;
break;
case 1:
a[i+2]=1;
break;
case 2:
a[i]=a[i+1]=1;
break;
case 3:
a[i+1]=a[i+2]=1;
}
bit<<=2;
}
else
{
if(a[i]==-1)
{
if(X/bit%2==0)
{
a[i+1]=1;
bit<<=1;
}
else
{
if(X/bit%4==1)
{
a[i+2]=1;
}
else
{
a[i+1]=a[i+2]=1;
}
bit<<=2;
}
}
else if(a[i+1]==-1)
{
if(X/bit%2)
{
a[i]=1;
}
else
{
a[i]=a[i+2]=1;
}
bit<<=1;
}
else
{
if(X/bit%2)
{
a[i]=1;
}
else
{
a[i+1]=1;
}
bit<<=1;
}
}
if(X<bit) break;
}
for(i=0;i<N;i++)
{
if(a[i]==1) Set(i,1);
else Set(i,0);
}
}
//*
int p[100010];
int aa[100010];
void Set(int loc,int val){
aa[loc]=val;
}
L con[8]={
0,1,0,3,1,0,2,0
};
L shi[8]{
0,2,1,2,1,1,2,2
};
L Bruno(int N,int A[]){
L ret=0,i,bit=1;
for(i=0;i<N;i+=3)
{
L temp=A[i]*4+A[i+1]*2+A[i+2];
ret+=bit*con[temp];
//printf("%lld %lld\n",bit,temp);
bit<<=shi[temp];
}
return ret;
}
int main()
{
L n,k,x;
scanf("%lld %lld %lld",&n,&k,&x);
for(int i=0;i<k;i++)
{
scanf("%lld",&p[i]);
}
Anna(n,x,k,p);
for(int i=0;i<n;i++)
{
printf("%d ",aa[i]);
}
puts("");
printf("%lld ",Bruno(n,aa));
}
//*/
#include "Brunolib.h"
#include <bits/stdc++.h>
#define L long long
using namespace std;
L con[8]={
0,1,0,3,1,0,2,0
};
L shi[8]{
0,2,1,2,1,1,2,2
};
L Bruno(int N,int A[]){
L ret=0,i,bit=1;
for(i=0;i<N;i+=3)
{
L temp=A[i]*4+A[i+1]*2+A[i+2];
ret+=bit*con[temp];
//printf("%lld %lld\n",bit,temp);
bit<<=shi[temp];
}
return ret;
}
Compilation message
Anna.cpp: In function 'int main()':
Anna.cpp:137:21: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
scanf("%lld",&p[i]);
~~~~~^
Anna.cpp:134:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld",&n,&k,&x);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Anna.cpp:137:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&p[i]);
~~~~~^~~~~~~~~~~~~~
/tmp/cc5nR3nA.o: In function `Set(int, int)':
grader_anna.c:(.text+0x50): multiple definition of `Set(int, int)'
/tmp/cczgEOj3.o:Anna.cpp:(.text+0x240): first defined here
/tmp/cc5nR3nA.o: In function `main':
grader_anna.c:(.text.startup+0x0): multiple definition of `main'
/tmp/cczgEOj3.o:Anna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status