解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); int m = scanner.nextInt(); int num = 0;//m个数总和 String str = ""; for (int i = 1; i <= n; i++) { num += i * 2; if (i % m == 0) { str += num / m + " "; num = 0; } } if (n % m != 0) str += num / (n % m) + " "; if (!str.equals("")) str = str.substring(0, str.length() - 1); System.out.println(str); } } }
0.0分
1 人评分
汽水瓶 (C语言代码)浏览:597 |
【绝对值排序】 (C++代码)浏览:670 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:748 |
C二级辅导-阶乘数列 (C语言代码)浏览:688 |
【金明的预算方案】 (C++代码)浏览:935 |
完数 (C语言代码)浏览:685 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:531 |
DNA (C语言代码)浏览:540 |
A+B for Input-Output Practice (VII) (C语言代码)浏览:521 |
陶陶摘苹果2 (C语言代码)浏览:595 |