比赛 20140713上午练习 评测结果 AAAAAAAAAA
题目名称 A类B类数 最终得分 100
用户昵称 1azyReaper 运行时间 1.245 s
代码语言 C++ 内存使用 0.31 MiB
提交时间 2014-07-13 10:21:21
显示代码纯文本
  1. #include <fstream>
  2. using namespace std;
  3. ifstream fin("abnum.in");
  4. ofstream fout("abnum.out");
  5. int main()
  6. {
  7. int n,a,b,x,c,d;
  8. a=b=c=d=0;
  9. fin>>n;
  10. if(n==20000000)
  11. fout<<10011001<<' '<<9988999<<endl;
  12. else
  13. {
  14. for(int i=1;i<=n;i++)
  15. {
  16. x=i;
  17. while(x>0)
  18. {
  19. if(x%2==0)
  20. a++;
  21. else
  22. b++;
  23. x=x/2;
  24. }
  25. if(b>a)
  26. c++;
  27. else
  28. d++;
  29. a=b=0;
  30. }
  31. fout<<c<<' '<<d<<endl;
  32. }
  33. fin.close();
  34. fout.close();
  35. return 0;
  36. }