akoj-1319-四方定理
2024-10-19 06:23:19
四方定理
Time Limit:1000MS Memory Limit:65536K
Total Submit:28 Accepted:11
Description
数论中著名的“四方定理”讲的是:所有自然数至多只要用四个数的平方和就可以表示。
Input
输入包含多行数据
每行输入一个n,(1<=n<=10000)
数据以EOF结束
Output
由于可能会出现多种情况,依次输出最小的a,b,c,d即可
即输出最小的a,然后输出最小的b,依此类推
Sample Input
110
211
520
Sample Output
0 1 3 10
0 3 9 11
0 0 6 22
Source
[Submit] [Go Back] [Status]
[Discuss]
#include <stdio.h> int main()
{
int n, i, j, x, y, s;
while ( ~scanf("%d", &n) )
{
for ( i=0; i<=n; i++ ) {
for ( j=0; j<=n; j++ ) {
for ( x=0; x<=n; x++ ) {
for ( y=0; y<=n; y++ )
{
s = i*i+j*j+x*x+y*y;
if ( s == n )
{
printf("%d %d %d %d\n", i, j, x, y);
break;
}
}
if ( s == n )
{
break;
}
}
if ( s == n )
{
break;
}
}
if ( s == n )
{
break;
}
}
}
}
最新文章
- 2003-Can&#39;t connect to mysql server on localhost (10061)
- 2.快速部署MySQL主从复制
- mysql-advanced-5.6.23-linux-glibc2.5-x86_64安装
- dedecms无法创建rss文件,提示DedeTag Engine Create File False
- (转)Linux上的Shebang符号(#!)
- unity3d遍历出Cube里面所有子对象
- poj 1840 Eqs (hash)
- absolute之整体布局实现
- 基于B/S模式的推送
- C# 课堂总结1-二进制转换
- Druid 详细介绍
- Mysql初学入门
- Error: Can&#39;t resolve &#39;babel-loader&#39;
- 微信支付提示System:access_denied
- 利用C#访问注册表获取软件的安装路径
- Redis 哨兵
- 安卓开发_深入理解Content Provider
- 服务器 nginx配置 防止其他域名绑定自己的服务器
- string和list互转
- C语言位操作--判断两整数是否异号
热门文章
- CentOS通过yum安装php7.0
- PHP中对汉字进行UNICODE编码和解码的实现
- [转]浅谈C++指针直接调用类成员函数
- EventUtil.addHandler方法
- 我的学习之路_第二十五_javaScript
- vim中常用基本命令
- org.apache.jasper.JasperException: - Page directive must not have multiple occurrences of pageencoding
- SpringMvc支持跨域访问,Spring跨域访问,SpringMvc @CrossOrigin 跨域
- Apple使用Apache Mesos重建Siri后端服务
- 51nod_1119:机器人走方格 V2