git reimport
This commit is contained in:
71
archive/2017.10/2017.10.26 - unsorted/С.java
Normal file
71
archive/2017.10/2017.10.26 - unsorted/С.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class С extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
|
||||
int[] states = new int[10];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
char op = in.nextString().charAt(0);
|
||||
int x = in.nextInt();
|
||||
|
||||
if (op == '&') {
|
||||
x ^= 1023;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 10; j++) {
|
||||
if (x % 2 == 1) {
|
||||
switch (op) {
|
||||
case '|':
|
||||
states[j] = 1;
|
||||
break;
|
||||
case '&':
|
||||
states[j] = 2;
|
||||
break;
|
||||
case '^':
|
||||
states[j] ^= 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
x /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
int alwaysZero = 0;
|
||||
int alwaysOne = 0;
|
||||
int xored = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
switch (states[i]) {
|
||||
case 1:
|
||||
alwaysOne += 1 << i;
|
||||
break;
|
||||
case 2:
|
||||
alwaysZero += 1 << i;
|
||||
break;
|
||||
case 3:
|
||||
xored += 1 << i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
alwaysZero ^= 1023;
|
||||
|
||||
out.println(3);
|
||||
out.println("| " + alwaysOne);
|
||||
out.println("& " + alwaysZero);
|
||||
out.println("^ " + xored);
|
||||
}
|
||||
}
|
28
archive/2017.10/2017.10.26 - unsorted/С.task
Normal file
28
archive/2017.10/2017.10.26 - unsorted/С.task
Normal file
@@ -0,0 +1,28 @@
|
||||
2 С
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
13 3
|
||||
| 3
|
||||
^ 2
|
||||
| 1
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
10 chelper.С
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.10.26
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
Reference in New Issue
Block a user