记录编号 93520 评测结果 AAAAAAAAAA
题目名称 [NOIP 2008]火柴棒等式 最终得分 100
用户昵称 Gravatardevil 是否通过 通过
代码语言 C++ 运行时间 0.014 s
提交时间 2014-03-26 20:45:56 内存使用 0.32 MiB
显示代码纯文本
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. int match[1800];
  8.  
  9. void getmatches();
  10. int main()
  11. {
  12. freopen("matches.in","r",stdin);
  13. freopen("matches.out","w",stdout);
  14. getmatches();
  15. int n;
  16. int cnt=0;
  17. cin>>n;
  18. for(int i=0;i<900;i++)
  19. for(int j=0;j<900;j++)
  20. {
  21. if(match[i]+match[j]+match[i+j]==(n-4)) cnt++;
  22. }
  23. cout<<cnt<<endl;
  24. return 0;
  25. }
  26. void getmatches()
  27. {
  28. match[0]=6;
  29. match[1]=2;
  30. match[2]=5;
  31. match[3]=5;
  32. match[4]=4;
  33. match[5]=5;
  34. match[6]=6;
  35. match[7]=3;
  36. match[8]=7;
  37. match[9]=6;
  38. for(int i=1;i<180;i++)
  39. for(int j=0;j<10;j++)
  40. {
  41. if(i<10) match[10*i+j]=match[i]+match[j];
  42. else
  43. {
  44. match[10*i+j]=match[i/10]+match[i%10]+match[j];
  45. }
  46. }
  47. }