HDU 2058 JAVA
来源:互联网 发布:淘宝商城衣服女装 编辑:程序博客网 时间:2024/04/27 23:08
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(); } }}
0 0
- HDU 2058 JAVA
- hdu acm hdu 2115 Java
- Exponentiation hdu 1063 java
- hdu 1313 (Java)
- 【Java】hdu 4043
- hdu 1242 Rescue<java>
- HDU 1002 JAVA
- hdu 2092(java)
- hdu 1063 java 高精度
- hdu 1106(java)
- hdu 1073(java)
- HDU-4762 Java高精度
- hdu 1002 java
- hdu 1089 java
- JAVA hdu 2192 MagicBuilding
- hdu 1001 java
- hdu 1002 java
- hdu 1003 java
- cookie与session的详细区别
- 【Zookeeper】源码分析之网络通信(三)
- P1522 牛的旅行
- 各种输入的总结
- win10系统安装oracle11g时遇到INS-13001环境不满足最低要求
- HDU 2058 JAVA
- SSM整合,spring4.3.6.RELEASE,springmvc,mybatis3.4.2,maven聚合项目整合
- ubuntu install google-pinyin
- Python(5):让Python更快
- react——表单
- 卷积神经网络的直观解释(笔记)
- Opencv中findContours函数改变输入图像问题
- 局部变量,局部静态变量,全局变量,全局静态变量区别:
- Java反射机制详解