四方定理

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;
}
}
}
}

最新文章

  1. 2003-Can&#39;t connect to mysql server on localhost (10061)
  2. 2.快速部署MySQL主从复制
  3. mysql-advanced-5.6.23-linux-glibc2.5-x86_64安装
  4. dedecms无法创建rss文件,提示DedeTag Engine Create File False
  5. (转)Linux上的Shebang符号(#!)
  6. unity3d遍历出Cube里面所有子对象
  7. poj 1840 Eqs (hash)
  8. absolute之整体布局实现
  9. 基于B/S模式的推送
  10. C# 课堂总结1-二进制转换
  11. Druid 详细介绍
  12. Mysql初学入门
  13. Error: Can&#39;t resolve &#39;babel-loader&#39;
  14. 微信支付提示System:access_denied
  15. 利用C#访问注册表获取软件的安装路径
  16. Redis 哨兵
  17. 安卓开发_深入理解Content Provider
  18. 服务器 nginx配置 防止其他域名绑定自己的服务器
  19. string和list互转
  20. C语言位操作--判断两整数是否异号

热门文章

  1. CentOS通过yum安装php7.0
  2. PHP中对汉字进行UNICODE编码和解码的实现
  3. [转]浅谈C++指针直接调用类成员函数
  4. EventUtil.addHandler方法
  5. 我的学习之路_第二十五_javaScript
  6. vim中常用基本命令
  7. org.apache.jasper.JasperException: - Page directive must not have multiple occurrences of pageencoding
  8. SpringMvc支持跨域访问,Spring跨域访问,SpringMvc @CrossOrigin 跨域
  9. Apple使用Apache Mesos重建Siri后端服务
  10. 51nod_1119:机器人走方格 V2