1080 两个数的平方和 基准时间限制:1 秒 空间限制:131072 KB 分值: 5         难度:1级算法题 给出一个整数N,将N表示为2个整数i j的平方和(i <= j),如果有多种表示,按照i的递增序输出.   例如:N = 130,130 = 3^2 + 11^2 = 7^2 + 9^2 (注:3 11同11 3算1种) Input 一个数N(1 <= N <= 10^9) Output 共K行:每行2个数,i j,表示N = i^2 + j^2(0 <= i…
给出一个整数N,将N表示为2个整数i与j的平方之和(i <= j),如果有多种表示,按照i的递增序输出. 例如:N = 130,130 = 3^2 + 11^2 = 7^2 + 9^2(注:3^2 + 11^2同11^2 + 3^2算1种)   输入 一个数N(1 <= N <= 10^9) 输出 共K行:每行2个数,i j,表示N = i^2 + j^2(0 <= i <= j). 如果无法分解为2个数的平方和,则输出No Solution 输入样例 130 输出样例 3…
没心情写数学题啦啊   好难啊 #include<bits/stdc++.h> using namespace std; set<int> s; set<int>::iterator it; int main () { s.clear(); ;i*i<=1e9;i++) s.insert(i*i); int n; scanf("%d",&n); ; ;i*i<=n/;i++) { int t = n-i*i; if(s.find(…
1080 两个数的平方和 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 给出一个整数N,将N表示为2个整数i j的平方和(i <= j),如果有多种表示,按照i的递增序输出. 例如:N = 130,130 = 3^2 + 11^2 = 7^2 + 9^2 (注:3 11同11 3算1种) Input 一个数N(1 <= N <= 10^9) Output 共K行:每行2个数,i j,表示N = i^2 + j^2(0 <= i &…
Given a non-negative integer c, your task is to decide whether there're two integers a and bsuch that a2 + b2 = c. Example 1: Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input: 3 Output: False Accepted 38,694 Submissions 117,992  …
题目: 1557 两个集合 题目来源: CodeForces 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 小X有n个互不相同的整数: p1,p2,...,pn .他想把这些整数分到两个集合A和B里边.但是要符合下面两个条件. ·        如果x属于A,那么a-x也肯定属于A. ·        如果x属于B,那么b-x也肯定属于B. 判断一下是否存在一种方案来分配这些数字到集合A,B中. 注意:如果一个集合为空也是可以的. Input 单组测试数据.…
[002-Add Two Numbers (单链表表示的两个数相加)] 原题 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. In…
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1684 题意: 新建一个位运算,求所有子集通过这个位运算后的答案的平方和是多少. 先想弱化版: 新建一个位运算,求所有子集通过这个位运算后的答案的和是多少. 枚举每一个二进制位,看有多少个子集能够使这一位为1 dp[i]表示前i个数中,能使枚举的这一位为1的方案数 根据第i个数选或者是不选转移 ans= Σ  2^j * 第j位的dp[n] 这里是平方和 设一个子集位运算…
题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1021 经典区间dp,dp[i][j] 表示将从 i 到 j 堆石子合并最小代价,长度为 j-i+1,可看做之前已经合并的 i 到 k 和 k 到 j 两堆石子合并,代价是 i 到 j 的石子数量: #include<iostream> #include<cstring> #include<algorithm> using namesp…
一个简单的小算法来获取两个数的最大公约数, public class Test { public static void main(String[] args) { long result = gcd(15, 3); System.out.println(result); } public static long gcd(long m, long n) { while (n != 0) { long rem = m % n; m = n; n = rem; } return m; } }…