问题 关于循环顺序
  • 板块P1586 四方定理
  • 楼主zysqh
  • 当前回复4
  • 已保存回复4
  • 发布时间2020/8/26 15:40
  • 上次更新2023/11/6 19:16:31
查看原帖
问题 关于循环顺序
224111
zysqh楼主2020/8/26 15:40

为什么正序能过 倒序不能过

#include <cstdio>
#include <iostream>
#define S 32768
using namespace std;
int f[S+10][6];
int t,n;
int ans;
int main(){
	cin>>t;
	f[0][0]=1;
	for(int i=1;i*i<=S;++i){
		for(int j=i*i;j<=S;++j){
			for(int k=1;k<=4;++k){
				f[j][k]+=f[j-i*i][k-1];
			}
		}
	}
	while(t--){
		cin>>n;
		ans=0;
		for(int i=1;i<=4;++i)ans+=f[n][i];
		cout<<ans<<endl;
	}
}
2020/8/26 15:40
加载中...