记录编号 296689 评测结果 AAAAAAAAAA
题目名称 [USACO Oct07] 贝茜的秘密牧场 最终得分 100
用户昵称 Gravataropen the window 是否通过 通过
代码语言 C++ 运行时间 1.444 s
提交时间 2016-08-15 20:56:03 内存使用 0.31 MiB
显示代码纯文本
  1. #include<cstdio>
  2. #include<cmath>
  3. #include<iostream>
  4. using namespace std;
  5. int tot,n;
  6. void dfs(int k,int ans)
  7. {
  8. if (k==4 && ans==n)
  9. {
  10. tot++;
  11. return ;
  12. }
  13. else if (k<4 && ans<=n)
  14. for (int i=0; i*i<=n; ++i)
  15. dfs(k+1,ans+i*i);
  16. }
  17. int main()
  18. {
  19. freopen("secpas.in","r",stdin);
  20. freopen("secpas.out","w",stdout);
  21. scanf("%d",&n);
  22. dfs(0,0);
  23. printf("%d\n",tot);
  24. }