Skip to content

Instantly share code, notes, and snippets.

@wingyplus
Created July 15, 2011 03:51
Show Gist options
  • Save wingyplus/1084028 to your computer and use it in GitHub Desktop.
Save wingyplus/1084028 to your computer and use it in GitHub Desktop.
Gweans
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");
}
}
}
}
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());
}
}
}
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);
}
}
}
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++;
}
}
}
}
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);
}
}
}
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;
}
}
}
@chanwit
Copy link

chanwit commented Jul 15, 2011

i--
i++
ควรใช้เป็น statement :)

@wingyplus
Copy link
Author

555

@wingyplus
Copy link
Author

บาสแนะนำครับ ฮา :P

@6LYTH3
Copy link

6LYTH3 commented Jul 16, 2011

RegEx น่าสนใจมาก

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment