Codeforces Round 946 (div3)
A. Phone Desktop
题意:
有 x x x个 1 ∗ 1 1*1 1∗1和 y y y个 2 ∗ 2 2*2 2∗2的网格,问最少需要多少个 3 ∗ 5 3*5 3∗5的网格可以存下。
题解:
,因为 3 ∗ 5 3*5 3∗5的网格可以由 11 11 11个 1 ∗ 1 1*1 1∗1和 1 1 1个 2 ∗ 2 2*2 2∗2的网格或者 7 7 7个 1 ∗ 1 1*1 1∗1和 2 2 2个 2 ∗ 2 2*2 2∗2的网格或者 15 15 15个 1 ∗ 1 1*1 1∗1的网格构成,所以先根据 2 ∗ 2 2*2 2∗2的数量去判断最少需要多少个网格,然后判断这些网格能否存下 1 ∗ 1 1*1 1∗1的网格,不够就再添加。
代码:
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<set>
#include<map>
#include<numeric>
#include<functional>
#include<stack>
using namespace std;
typedef long long ll;
void solve()
{
int x, y;
cin >> x >> y;
int s=(y+1)/2;
if(s*15-y*4>=x){
cout<<s<<endl;
}
els