让我们用字母B来表示“百”、字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数。例如234应该被输出为BBSSS1234,因为它有2个“百”、3个“十”、以及个位的4。
输入格式:每个测试输入包含1个测试用例,给出正整数n(<1000)。
输出格式:每个测试用例的输出占一行,用规定的格式输出n。
输入样例1:234输出样例1:
BBSSS1234输入样例2:
23输出样例2:
SS123
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int num = Integer.parseInt(scanner.nextLine()); int count100 = num / 100; int count10 = num % 100 / 10; int count1 = num % 10; StringBuilder builder = new StringBuilder(); for(int i=0; i<count100; i++){ builder.append("B"); } for(int i=0; i<count10; i++){ builder.append("S"); } for(int i=0; i<count1;){ builder.append(++i); } System.out.println(builder.toString()); } }
评测结果
时间 | 结果 | 得分 | 题目 | 语言 | 用时(ms) | 内存(kB) | 用户 |
---|---|---|---|---|---|---|---|
4月30日 08:57 | 答案正确 | 15 | 1006 | Java (javac 1.6.0) | 78 | 10696 | zspring |
测试点
测试点 | 结果 | 用时(ms) | 内存(kB) | 得分/满分 |
---|---|---|---|---|
0 | 答案正确 | 77 | 10696 | 4/4 |
1 | 答案正确 | 77 | 10440 | 4/4 |
2 | 答案正确 | 77 | 10556 | 1/1 |
3 | 答案正确 | 77 | 10440 | 1/1 |
4 | 答案正确 | 78 | 10568 | 1/1 |
5 | 答案正确 | 77 | 10440 | 1/1 |
6 | 答案正确 | 77 | 10440 | 1/1 |
7 | 答案正确 | 77 | 10440 | 1/1 |
8 | 答案正确 | 77 | 10440 | 1/1 |