题目1036:Old Bill
参考代码:
<strong>
</strong>import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
public class Main {
public static void main(String arg[]){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int num = sc.nextInt();
Integer m = sc.nextInt()*100+sc.nextInt()*10+sc.nextInt();
String s=m.toString();
int k = 10000/num-1;
int l = 100000/num+1;
int cost=0;
String string = "0";
for(int i=k;i<=l;i++)
{
Integer total = num*i;
String total1 = total.toString();
if(total1.length()==5){
String total2=total1.substring(1, 4);
if(total2.equals(s))
{
cost = i;
string = total1;
}
}
}
if(cost==0) System.out.println(0);
else System.out.println(string.charAt(0)+" "+string.charAt(string.length()-1)+" "+cost);
}
}
}