importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[] args){Scanner sc =newScanner(System.in);int n = sc.nextInt();char c = sc.next().charAt(0);sc.close();int m =(int)Math.sqrt((n +1)/2);for(int i =0; i <2* m -1; i++){if(i>(2*m-1)/2){for(int j =0; j <2* m -1; j++){if(i > j && i + j <2* m -2){System.out.print("/");}elseif(i < j && i + j >2* m -2){System.out.print("\\");}else{System.out.print(c);}}}elseif(i<(2*m-1)/2){for(int j =0; j <2* m -1; j++){if(i > j && i + j <2* m -2){System.out.print("\\");}elseif(i < j && i + j >2* m -2){System.out.print("/");}else{System.out.print(c);}}}else{for(int j =0; j <2* m -1; j++){if(i > j && i + j <2* m -2){System.out.print("|");}elseif(i < j && i + j >2* m -2){System.out.print("|");}else{System.out.print(c);}}}System.out.println();}System.out.println(n -2* m * m +1);}}
old bill
题目描述
Among grandfather's papers a bill was found.
72 turkeys $_679_
The first and the last digits of the number that obviously represented the total price of those turkeys are replaced here by blanks (denoted _), for they are faded and are illegible. What are the two faded digits and what was the price of one turkey?
We want to write a program that solves a general version of the above problem.
N turkeys $_XYZ_
The total number of turkeys, N, is between 1 and 99, including both. The total price originally consisted of five digits, but we can see only the three digits in the middle. We assume that the first digit is nonzero, that the price of one turkeys is an integer number of dollars, and that all the
turkeys cost the same price.
Given N, X, Y, and Z, write a program that guesses the two faded digits and the original price. In case that there is more than one candidate for the original price, the output should be the most expensive one. That is, the program is to report the two faded digits and the maximum price per turkey for the turkeys.
输入: The first line of the input file contains an integer N (0<N<100), which represents the number of turkeys. In the following line, there are the three decimal digits X, Y, and Z., separated by a space, of the original price $_XYZ_.
输出: For each case, output the two faded digits and the maximum price per turkey for the turkeys. If there is no the integer price, output 0 directly。
// OldBill问题JAVA实现importjava.awt.print.Printable;importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[] args){// TODO 自动生成的方法存根Scanner in =newScanner(System.in);while(in.hasNext()){int turkeynum;int x,y,z;
turkeynum = in.nextInt();
x = in.nextInt();
y = in.nextInt();
z = in.nextInt();int temp0prise = x*100+ y*10+ z;
loop1:{for(int i =9; i >0; i--){int temp1prise = temp0prise + i*1000;
loop2:for(int j =9; j >=0; j--){int temp2prise = j + temp1prise*10;if(temp2prise%turkeynum ==0){int priseperturkey = temp2prise/turkeynum;System.out.println(i +" "+ j +" "+ priseperturkey);break loop1;}}}System.out.println(0);}}}}
java a+b Problem题目描述对于给定的两个整数a和b,求它们的和。输入描述:a b输出描述:a,b之和Sampleinput:555 445output:1000 import java.util.Scanner; public class Main { public static void main(String[] arg) { Scanner sc=new Scanner(System.in);