Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Q2 {
- public static boolean swing(int p, int q) {
- return (p%q) == (p-(q*p/q));
- }
- public static boolean polka(int p, int q) {
- return (p%q) < (p-q);
- }
- public static void testA() {
- for (int i = 1; i <= 10; i++) {
- for (int j = 1; j <= 10; j++) {
- System.out.println("i: "+i+"\nj: "+j+"\n"+(swing(i,j)==polka(i,j)));
- }
- }
- }
- public static void testC() {
- for (int i = 1; i <= 10; i++) {
- for (int j = 1; j <= 10; j++) {
- if(i>=j)
- System.out.println("i: "+i+"\nj: "+j+"\n"+(swing(i,j)==polka(i,j)));
- }
- }
- }
- public static void testD() {
- for (int i = 1; i <= 10; i++) {
- for (int j = 1; j <= 10; j++) {
- if(i<j)
- System.out.println("i: "+i+"\nj: "+j+"\n"+(swing(i,j)==polka(i,j)));
- }
- }
- }
- public static void testE() {
- for (int i = 1; i <= 10; i++) {
- for (int j = 1; j <= 10; j++) {
- if(i%j==0)
- System.out.println("i: "+i+"\nj: "+j+"\n"+(swing(i,j)==polka(i,j)));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment