PAT乙级 1066 图像过滤 (13/15 分) Java 实现

 测试点3 又双叒叕超时。实在是没想到15分的题目也卡时间。

import java.io.*;

public class pat1066 {

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StreamTokenizer st = new StreamTokenizer(br);
		st.nextToken();
		int M = (int)st.nval;
		st.nextToken();
		int N = (int)st.nval;
		st.nextToken();
		int A = (int)st.nval;
		st.nextToken();
		int B = (int)st.nval;
		st.nextToken();
		int G = (int)st.nval;
		for(int i=0;i<M;i++) {
			for(int j=0;j<N;j++) {
				st.nextToken();
				int num = (int)st.nval;
				if(num>=A && num<=B) System.out.printf("%03d", G);
				else System.out.printf("%03d", num);
				if(j==N-1) System.out.println();
				else System.out.print(" ");
			}
		}
	}

}

上一篇:Java学习笔记125——可变参数


下一篇:socket-3