Created
July 15, 2011 03:51
-
-
Save wingyplus/1084028 to your computer and use it in GitHub Desktop.
Gweans
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.Scanner; | |
public class gweans { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
int testCase = s.nextInt(); | |
s.nextLine(); | |
while(testCase-- > 0) { | |
s.nextLine(); | |
String l1 = s.nextLine().replaceAll("[a-z]", "").replaceAll(" ",""); | |
s.nextLine(); | |
String l2 = s.nextLine().replaceAll("[a-z]", "").replaceAll(" ",""); | |
if (l1.equals(l2)) { | |
System.out.println("SAME"); | |
} else { | |
System.out.println("DIFFERENT"); | |
} | |
} | |
} | |
} |
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.Scanner; | |
public class gweans2 { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
int line = s.nextInt(); | |
int i = 1; | |
while(line-- > 0) { | |
int n = s.nextInt(); | |
StringBuffer word = new StringBuffer(s.next()); | |
word.replace(n-1, n, ""); | |
System.out.println(i++ + " " + word.toString()); | |
} | |
} | |
} |
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.Scanner; | |
public class gweans3 { | |
public static void main(String[] args) { | |
Scanner s = new Scanner (System.in); | |
while(true) { | |
int x = s.nextInt(); | |
if (x == 0) break; | |
int o = (int) Math.pow(2, (new StringBuffer(Integer.toBinaryString(x))).reverse().indexOf("1") ); | |
System.out.println(o); | |
} | |
} | |
} |
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.Scanner; | |
public class gweans4 { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
int line = s.nextInt(); | |
for (int i = 1; i <= line; i++) { | |
int x = s.nextInt(); | |
int count = 0; | |
int input = 1; | |
while(true) { | |
if (input % 7 == 0 || Integer.toString(input).indexOf("7") >= 0) { | |
count++; | |
if (count == x) { | |
System.out.println(input - count + 1); | |
break; | |
} | |
} else { | |
count = 0; | |
} | |
input++; | |
} | |
} | |
} | |
} |
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.Scanner; | |
public class gweans6 { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
int line = s.nextInt(); | |
for (int i = 1; i <= line; i++ ) { | |
int n = s.nextInt(); | |
int sum = 0; | |
for (int j = 1; j <= n; j++) { | |
int p = s.nextInt(); | |
if (j == n) { | |
sum += p; | |
} else { | |
sum += p - 1; | |
} | |
} | |
System.out.println(sum); | |
} | |
} | |
} |
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.Scanner; | |
public class gweans7 { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
while(true) { | |
int n = s.nextInt(); | |
int m = s.nextInt(); | |
if (n == 0 && m == 0) break; | |
int count = 0; | |
int[] a = new int[n]; | |
for (int i = 1; i <= m; i++) { | |
int input = s.nextInt(); | |
a[input-1]++; | |
} | |
for (int j = 0; j < a.length; j++) { | |
if (a[j] > 1) count++; | |
} | |
System.out.println(count); | |
count = 0; | |
} | |
} | |
} |
555
บาสแนะนำครับ ฮา :P
RegEx น่าสนใจมาก
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i--
i++
ควรใช้เป็น statement :)