【九度OJ】1015【模拟】【A+B系列2006】

来源:互联网 发布:弹丸论破2知乎 编辑:程序博客网 时间:2024/05/22 05:05

代码:

package Test1;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.io.StreamTokenizer;public class Test42_1015 {/** * by qr jobdu 1015 2014-8-23 * @throws IOException  */public static void main(String[] args) throws IOException {StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));while(true){st.nextToken();int A=(int)st.nval;st.nextToken();int B=(int)st.nval;st.nextToken();int K=(int)st.nval;if(A==0 && B==0)break;int chushu=(int)Math.pow(10, K);int A1=A%chushu;int B1=B%chushu;if(A1==B1)System.out.println("-1");elseSystem.out.println(A+B);}}}


0 0
原创粉丝点击