Last active
March 28, 2017 14:14
-
-
Save getsadzeg/a3ae27a4a5535e86bb7e18808b7e552f to your computer and use it in GitHub Desktop.
GEOI2017, #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class Rectangle { | |
public static void main(String[] args) { | |
Map map = new HashMap<>(); | |
int n = 5; | |
int counter = 0; | |
if(n>0) { | |
for(int x=1; x<n/2; x++) { | |
if(doesDivide(x, n) && !map.containsValue(x)) { | |
counter++; | |
System.out.println("sizes: " + x + " " + getY(x,n)); //not necessary to print this | |
map.put(x, getY(x,n)); | |
} | |
} | |
} | |
System.out.println(counter); | |
} | |
public static boolean doesDivide(int x, int n) { | |
return (n-x)%(1+2*x) == 0; | |
} | |
public static int getY(int x, int n) { | |
int y = 0; | |
if(doesDivide(x, n)) y = (n-x)/(1+2*x); | |
return y; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment