# BOI 2016, day 1

 Start: 2016-05-12 09:00:00 End: 2016-05-12 14:00:00

CSES - BOI 2016, day 1 - Results
History
2016-05-12 13:58:350
2016-05-12 13:52:500
2016-05-12 13:49:410
2016-05-12 13:47:180
2016-05-12 13:42:130
 Task: Spiral Sender: markuskl Submission time: 2016-05-12 13:58:35 Language: Java Status: READY Score: 0

## Test results

 test verdict time (s) group #1 WRONG ANSWER 0.10 / 1.50 1 details #2 WRONG ANSWER 0.11 / 1.50 2 details #3 WRONG ANSWER 0.10 / 1.50 3 details #4 WRONG ANSWER 0.11 / 1.50 4 details #5 WRONG ANSWER 0.10 / 1.50 5 details

## Code

```import java.util.Scanner;

public class Spiral {

public static void main(String[] args) {
IO io = new IO();
//		Scanner io = new Scanner(System.in);

io.nextLong();
int Q = io.nextInt();
for(int i = 0; i<Q; i++){
io.println(cord(io.nextLong(),io.nextLong()));
io.nextLong();
io.nextLong();
}
io.close();
}

static long cord(long x, long y){
if(x == 0 && y == 0)
return 1;
long inside = (Math.max(Math.abs(x)-1, Math.abs(y)-1));
long in2 = (long) (Math.pow(inside*2+1, 2) % 1000000007);
long max = inside+1;

if(y == max){
return ((in2+inside*2+2+y-x) % 1000000007);
}
else if(-1*y == max){
return ((in2+inside*6+6-y+x) % 1000000007);
}
else if(-1*x == max){
return ((in2+inside*4+4-x-y) % 1000000007);
}
else {
return ((in2+x+y) % 1000000007);
}

}

}```

## Test details

### Test 1

Group: 1

input
`1000 100-709 0 1000 123-621 -1000 -102 -435-602 -560 276 -356-945 -590 0 -468...`
view   save

correct output
`78805700863312708250790332953165899558016315...`
view   save

user output
`20114344002380145077935736362620246...`
view   save

### Test 2

Group: 2

input
`1000000000 100181053719 1000000000 181053719...`
view   save

correct output
`81894649275063516319383002666063241146072376...`
view   save

user output
`81894649175063515419382996966063233046072351...`
view   save

### Test 3

Group: 3

input
`100000 100-88233 -87279 -49871 52277-86645 -7997 48948 30702-79916 -36210 -21257 -168210 57331 93163 100000...`
view   save

correct output
`986592951708386765853365951826359432233727...`
view   save

user output
`14042445229518533546384176147316823919645860...`
view   save

### Test 4

Group: 4

input
`1000000000 1001 1 21134200 7199831021 1 929463279 10000000001 1 68450838 11 1 84417340 297177199...`
view   save

correct output
`69596115895736017613757576852223214058884045...`
view   save

user output
`33333...`
view   save

### Test 5

Group: 5

`1000000000 100-857489445 -1000000000 -432836...`
`902627632581519884819269364857298983278402948...`
`14251073714781371211728302717826687623833073...`