Submission #222412

#TimeUsernameProblemLanguageResultExecution timeMemory
222412dantoh000Popcount (COCI19_popcount)C++14
0 / 110
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; string tostring(int x){ string s; if (x == 0) return "0"; while (x){ s += (x%10)+'0'; x /= 10; } reverse(s.begin(),s.end()); return s; } int main(){ int n,k; scanf("%d%d",&n,&k); vector<string> ans; int num = n/4; for (int i = 1; i <= num; i++){ ans.push_back("A=(A>>4)+((A&1)+(A&2)+(A&3)+(A&4))<<"+tostring(n-i*4)+")"); } if (n % 4 == 1){ ans.push_back("A=(A>>1)+(A&1)"); } else if (n%4 == 2){ ans.push_back("A=(A>>2)+(A&1)+(A&2)"); } else if (n%4 == 3){ ans.push_back("A=(A>>3)+(A&1)+(A&2)+(A&3)"); } printf("%d\n",ans.size()); for (auto x : ans){ cout << x << endl; } }

Compilation message (stderr)

popcount.cpp: In function 'int main()':
popcount.cpp:30:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::__cxx11::basic_string<char> >::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",ans.size());
                   ~~~~~~~~~~^
popcount.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...