比赛 20101101 评测结果 EEEEWEWWWE
题目名称 漂亮字串 最终得分 0
用户昵称 苏轼 运行时间 0.745 s
代码语言 C++ 内存使用 2.83 MiB
提交时间 2012-11-05 11:00:43
显示代码纯文本
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstdlib>
  4. using namespace std;
  5. int m,n,q,w;
  6. int main()
  7. {
  8. freopen ("bs.in","r",stdin);
  9. freopen ("bs.out","w",stdout);
  10. while ((cin>>m>>n>>q>>w))
  11. {
  12. if (q==0)
  13. {
  14. cout<<w<<endl;
  15. continue;
  16. }
  17. if (w==0)
  18. {
  19. cout<<q<<endl;
  20. continue;
  21. }
  22. q=min(q,n);
  23. w=min(w,m);
  24. if ((n/q)>(m/w))
  25. {
  26. cout<<(m+q*((m/w)+1))<<endl;
  27. continue;
  28. }
  29. if ((m/w)>(n/q))
  30. {
  31. cout<<(n+w*((n/q)+1))<<endl;
  32. continue;
  33. }
  34. if ((n/q)==(m/w))
  35. {
  36. cout<<((n/q)*q+(m/w)*w+max(n%q,m%w))<<endl;
  37. continue;
  38. }
  39. }
  40. return 0;
  41. }