首页 > 其他分享 >Sum of Squares Theorems

Sum of Squares Theorems

时间:2023-01-29 09:34:31浏览次数:39  
标签:mathbb int positive Sum Theorems Squares sum

这个在Cryptography里有用,因为对于大的数找起来很难

Legendre's three square theorem: a positive integer can be expressed as a sum of 4 squares if and only if it is not of the form $4^a(8b+7)$ for integers $a,b$

Lagrange's Four Square Theorem / Bachet's conjecture: all positive integers can be expressed as a sum of 4 squares ($\forall n\in\mathbb{Z}^+,\exists a,b,c,d\in\mathbb{N}\text{ s.t. }n=a^2+b^2+c^2+d^2$)

一个用来算较小数的小代码

#include<bits/stdc++.h>
using namespace std;
int a,b,s[11111];
int main(){
	for(int i=0;i<50;i++){
		for(int j=i;j<50;j++){
			for(int k=j;k<50;k++){
				s[i*i+j*j+k*k]=1;
			}
		}
	}
	cin>>a>>b; // enter a range of values: [a,b)
	for(int i=a;i<b;i++){
		cout<<i<<" "<<s[i]<<endl;
		// 1 means expressible as the sum of 3 squares, 0 otherwise
	}
	return 0;
} 

  

标签:mathbb,int,positive,Sum,Theorems,Squares,sum
From: https://www.cnblogs.com/hazel-wu/p/17071739.html

相关文章

  • My technical summary in 2022
    IntroIt'squitetoughformein2022.Iwentthroughchangingjob,injuryandcovidepidemic.AboutTechnology,IlearnedcudaandGPUprogrammingatthebeg......
  • vue2+SummerNote
    简介:想给加一个富文本编辑器到页面上,选择了summernote。接下来开始把summernote往vue这个框架里塞,死活塞不进去。最后把vue3回退到vue2,世界清净了。大致过程:下载相关包,引......
  • 2-sum 和 3-sum 问题的快速解法
    用科学方法分析程序中介绍了3-sum问题的暴力解法(ThreeSum)——用三个嵌套的for循环来求和为0的三元组个数,增长数量级为立方级别。类似地,对于2-sum问题(找出一个输入......
  • Consumer<T>函数式编程总结
    publicclassParent{publicvoidgetName(Stringname){System.out.println("name:"+name);}}publicclassSonextendsParent{@Ove......
  • CF622F The Sum of the k-th Powers 题解
    观前提示本题解仅提供一个理论复杂度正确的解法,因为本题模数为\(10^9+7\),没有优秀\(\text{MTT}\)板子的我被卡常了。正文部分不妨设\(S_{n,m}=\sum_{i=0}^{n-1}i^m......
  • D. Many Perfect Squares
    D.ManyPerfectSquaresYouaregivenaset$a_1,a_2,\ldots,a_n$ofdistinctpositiveintegers.Wedefinethesquarenessofaninteger$x$asthenumberof......
  • J Tokitsukaze and Sum of MxAb【2023牛客寒假算法基础集训营2】
    J TokitsukazeandSumofMxAb原题链接题意给出长为n的序列,对于所有的i,j求max\((|a_i-a_j|,|a_i+a_j|)\)之和思路对于两个负数\(a_i\)和\(a_j\),max\((|a_i-......
  • Difference Between Maximum and Minimum Price Sum
    DifferenceBetweenMaximumandMinimumPriceSumThereexistsanundirectedandinitiallyunrootedtreewith$n$nodesindexedfrom$0$to$n-1$.Youaregiv......
  • LeetCode Top 100 Liked Questions 64. Minimum Path Sum (Java版; Medium)
    ​​welcometomyblog​​LeetCodeTop100LikedQuestions64.MinimumPathSum(Java版;Medium)题目描述Givenamxngridfilledwithnon-negativenumbers,fi......
  • 14.Pytest常用插件:pytest-assume多重断言
    一、前言在自动化测试过程中,我们执行完用例之后,需要验证脚本执行的结果和预期的结果是否一致,来达到断言测试用例是否执行成功。一般情况下我们常用的断言方式是assert+......