#include <bits/stdc++.h>
using namespace std;
int N, K;
void subtask1(){
if(N%2 == 1){
printf("%d\n",(N-1)/2);
for(int i = 1;i < N;i += 2){
printf("A=((A+(((A&(1<<%d))>>%d)-(A&(1<<%d))))+(((A&(1<<%d))>>%d)-(A&(1<<%d))))\n", i, i, i, i + 1, i + 1,i + 1);
}
}
else{
printf("%d\n",N-1);
for(int i = 1;i < N;i++){
printf("A=((A+((A&(1<<%d))>>%d))-(A&(1<<%d)))\n", i, i, i);
}
}
}
void subtask2(){
vector<string> ans;
bool mode = false;
int lines = 0;
for(int i = 1;i < N;){
if(!mode){
lines++;
}
else{
lines++;
}
if(i % 4 == (N-1) % 4 && i >= 4) mode = true;
if(mode && i + 4 < N)i += 4;
else i++;
}
mode = false;
printf("%d\n",lines);
for(int i = 1;i < N;){
if(!mode){
printf("A=(((A&(1<<%d))>>%d)-(A&(1<<%d))))\n", i, i, i);
}
else{
printf("smth\n");
}
if(i % 4 == (N-1) % 4 && i >= 4) mode = true;
if(mode && i + 4 < N)i += 4;
else i++;
}
}
//A=((A+(((A&(1<<%d))>>%d)))-((A&(1<<%d))))
int main(){
cin >> N >> K;
if(N == K + 1) subtask1();
else subtask2();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Accepted. |
2 |
Correct |
4 ms |
256 KB |
Accepted. |
3 |
Correct |
5 ms |
384 KB |
Accepted. |
4 |
Correct |
4 ms |
384 KB |
Accepted. |
5 |
Correct |
5 ms |
384 KB |
Accepted. |
6 |
Correct |
5 ms |
256 KB |
Accepted. |
7 |
Correct |
5 ms |
256 KB |
Accepted. |
8 |
Correct |
4 ms |
256 KB |
Accepted. |
9 |
Correct |
4 ms |
384 KB |
Accepted. |
10 |
Correct |
4 ms |
256 KB |
Accepted. |
11 |
Correct |
5 ms |
256 KB |
Accepted. |
12 |
Correct |
5 ms |
384 KB |
Accepted. |
13 |
Correct |
5 ms |
256 KB |
Accepted. |
14 |
Correct |
4 ms |
256 KB |
Accepted. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Incorrect number of commands. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Accepted. |
2 |
Incorrect |
5 ms |
256 KB |
Incorrect number of commands. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Incorrect number of commands. |
2 |
Halted |
0 ms |
0 KB |
- |