Submission #222522

# Submission time Handle Problem Language Result Execution time Memory
222522 2020-04-13T08:39:37 Z jamielim Popcount (COCI19_popcount) C++14
0 / 110
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

long long X=42;
long long Y=47;

int main(){
	long long n,k;
	scanf("%lld%lld",&n,&k);
	if(n<=47){
		Y=n;
		string start="A=(((A-(A&" + to_string((1LL<<Y)-1) + "))>>" + to_string(Y) + ")+((A&1)";
		for(long long i=1;i<Y-1;i++){
			start+="+(((A&" + to_string(1LL<<i) + ")>>" + to_string(i) + ")";
		}
		start+="+((A&" + to_string(1LL<<(Y-1)) + ")>>" + to_string(Y-1) + ")";
		for(int i=-1;i<Y-1;i++)start+=")";
		printf("%s\n",start.c_str());
		return 0;
	}
	string start="A=(((A-(A&" + to_string((1LL<<Y)-1) + "))>>" + to_string(Y-9) + ")+((A&1)";
	for(long long i=1;i<Y-1;i++){
		start+="+(((A&" + to_string(1LL<<i) + ")>>" + to_string(i) + ")";
	}
	start+="+((A&" + to_string(1LL<<(Y-1)) + ")>>" + to_string(Y-1) + ")";
	for(int i=-1;i<Y-1;i++)start+=")";
	//printf("%d %s\n",(int)start.length(),start.c_str());
	
	string rep="A=((A&511)+(((A-(A&" + to_string((1LL<<(X+9))-1) + "))>>" + to_string(X) + ")";
	for(long long i=9;i<X+8;i++){
		rep+="+(((A&" + to_string(1LL<<i) + ")>>" + to_string(i) + ")";
	}
	rep+="+((A&" + to_string(1LL<<(X+8)) + ")>>" + to_string(X+8) + ")";
	for(int i=7;i<X+8;i++)rep+=")";
	//printf("%d %s\n",(int)rep.length(),rep.c_str());
	
	printf("%s\n",start.c_str());
	n-=Y;
	while(n>0){
		printf("%s\n",rep.c_str());
		n-=X;
	}
}

Compilation message

popcount.cpp: In function 'int main()':
popcount.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Wrong output format.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Wrong output format.
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Wrong output format.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Wrong output format.
2 Halted 0 ms 0 KB -