国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Java > 正文

HDU 2058 JAVA

2019-11-06 07:21:01
字體:
供稿:網(wǎng)友

PRoblem Description Given a sequence 1,2,3,……N, your job is to calculate all the possible sub-sequences that the sum of the sub-sequence is M.

Input Input contains multiple test cases. each case contains two integers N, M( 1 <= N, M <= 1000000000).input ends with N = M = 0.

Output For each test case, print all the possible sub-sequence that its sum is M.The format is show in the sample below.print a blank line after each test case.

Sample Input 20 10 50 30 0 0

Sample Output [1,4] [10,10]

[4,8] [6,9] [9,11] [30,30]

import java.util.*;class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); while (cin.hasNext()) { long n = cin.nextInt(); long m = cin.nextInt(); if (n == 0 && m == 0) break; long d = 0; for (int i = (int) Math.sqrt(2 * m); i > 0; i--) { d = m - (i + i * i) / 2; if (d % i == 0) System.out.println("[" + (d / i + 1) + "," + (d / i + i) + "]"); } System.out.println(); } }}
上一篇:HDU 2059 JAVA

下一篇:HDU 2057 JAVA

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 台山市| 崇文区| 钦州市| 临洮县| 宜兰市| 女性| 方正县| 新宾| 溆浦县| 上饶市| 惠安县| 句容市| 绥芬河市| 武城县| 越西县| 平安县| 古蔺县| 新沂市| 类乌齐县| 峡江县| 南川市| 中西区| 锡林郭勒盟| 高雄县| 河西区| 张家口市| 铜川市| 英德市| 深水埗区| 延长县| 景德镇市| 丰县| 邛崃市| 万荣县| 焦作市| 临夏市| 沧州市| 盘山县| 运城市| 河曲县| 孟村|