两个数的平方和
来源:互联网 发布:linux文件夹命名规则 编辑:程序博客网 时间:2024/05/18 02:50
给出一个整数N,将N表示为2个整数i j的平方和(i <= j),如果有多种表示,按照i的递增序输出。
例如:N = 130,130 = 3^2 + 11^2 = 7^2 + 9^2 (注:3 11同11 3算1种)
#include <iostream>#include <math.h>using namespace std;int input[40000];int main(){ int N; cin >> N; int maxVal = sqrt(N); for (int i = 0; i <= maxVal; i++) { input[i] = i*i; } int left = 0; int right = maxVal; bool found = false; while (left <= right) { int temp = input[left] + input[right]; if (temp == N) { cout << left << " " << right << endl; found = true; left++; } else if (temp > N) { right--; } else { left++; } } if (!found) { cout << "No Solution" << endl; } return 0;}
0 0
- 两个数的平方和
- 两个数的平方和
- 两个数的平方和
- 两个数的平方和,Java
- 计算两个数的平方和
- 1080 两个数的平方和
- <数论> 两个数的平方和
- 两个数的平方和的平方根
- 51nod 1080:两个数的平方和
- 51NOD 1080 两个数的平方和
- 51nod 1080 两个数的平方和
- 51nod1080 两个数的平方和
- 51nod 1080 两个数的平方和
- 51nod-1080 两个数的平方和
- 51nod-【1080 两个数的平方和】
- 51nod 1080 两个数的平方和
- 51nod 1080 两个数的平方和
- 51nod 1080 两个数的平方和
- C#简单实现26进制
- 内存,磁盘,cache等访问速度
- slam闭环检测
- Thread的中断机制(interrupt)
- ZOJ 3623 Battle Ships(完全背包)
- 两个数的平方和
- 网易2017 [编程题] 调整队形
- Monkey初体验
- UE4 在win10 中右键没有GenerateProjectFiles情况解决
- UESTC
- 线段树水题
- java 想交换两个数的值,用函数该怎么写?
- opencv3.1.0添加opencv_contrib失败——ocv_download
- 高薪面试系列一.HR