比赛 |
20101101 |
评测结果 |
EEEEWEWWWE |
题目名称 |
漂亮字串 |
最终得分 |
0 |
用户昵称 |
苏轼 |
运行时间 |
0.745 s |
代码语言 |
C++ |
内存使用 |
2.83 MiB |
提交时间 |
2012-11-05 11:00:43 |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- #include<cstdlib>
- using namespace std;
- int m,n,q,w;
- int main()
- {
- freopen ("bs.in","r",stdin);
- freopen ("bs.out","w",stdout);
- while ((cin>>m>>n>>q>>w))
- {
- if (q==0)
- {
- cout<<w<<endl;
- continue;
- }
- if (w==0)
- {
- cout<<q<<endl;
- continue;
- }
- q=min(q,n);
- w=min(w,m);
- if ((n/q)>(m/w))
- {
- cout<<(m+q*((m/w)+1))<<endl;
- continue;
- }
- if ((m/w)>(n/q))
- {
- cout<<(n+w*((n/q)+1))<<endl;
- continue;
- }
- if ((n/q)==(m/w))
- {
- cout<<((n/q)*q+(m/w)*w+max(n%q,m%w))<<endl;
- continue;
- }
- }
- return 0;
- }