We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e1d9c9 commit 592dce0Copy full SHA for 592dce0
src/class143/Code04_MomoEquation1.java
@@ -112,14 +112,19 @@ public static void main(String[] args) throws IOException {
112
l = (long) in.nval - 1;
113
in.nextToken();
114
r = (long) in.nval;
115
- in.nextToken();
116
- x = (int) in.nval;
117
- prepare();
118
- for (int i = 2, vi; i <= n; i++) {
+ x = 0;
+ for (int i = 1, vi; i <= n; i++) {
119
120
vi = (int) in.nval;
121
- for (int j = 0; j < x; j++) {
122
- addEdge(j, (j + vi) % x, vi);
+ if (vi != 0) {
+ if (x == 0) {
+ x = vi;
+ prepare();
123
+ } else {
124
+ for (int j = 0; j < x; j++) {
125
+ addEdge(j, (j + vi) % x, vi);
126
+ }
127
128
}
129
130
out.println(compute());
0 commit comments