Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers? Example 1: Input: 5 Output: 2 Explanation: 5 = 5 = 2 + 3 Example 2: Input: 9 Output: 3 Explanation: 9 = 9 = 4 + 5 = 2 + 3 + 4 Example 3: Input: 15 Ou
https://vjudge.net/problem/UVA-1210 题意: 输入整数n,有多少种方案可以把n写成若干个连续素数之和? 思路: 先素数打表,然后求个前缀和. #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<queue> using namespace std; typedef long long ll; +; int n
public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { System.out.println("please input a positive integer: "); int n = sc.nextInt(); getSubInteger(n); System.out.println("========================="