# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
222428 | 2020-04-13T07:07:15 Z | dantoh000 | Popcount (COCI19_popcount) | C++14 | 5 ms | 384 KB |
#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-1)/4; for (int i = 1; i <= num; i++){ ans.push_back("A=(A>>4)+(((A&1)+(A&2)+(A&4)+(A&8))<<"+tostring(n-i*4-1)+")"); } 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&4)"); } else if (n%4 == 0){ ans.push_back("A=(A>>4)+(A&1)+(A&2)+(A&3)+(A&8)"); } printf("%d\n",ans.size()); for (auto x : ans){ cout << x << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 256 KB | Wrong command format. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Wrong command format. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Wrong command format. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 256 KB | Incorrect number of commands. |
2 | Halted | 0 ms | 0 KB | - |