# No one wrote it but I wrote it myself Horseshoe disease 23 weeks

```#include<bits/stdc++.h>

using namespace std;
int n,m,k,q,p,x,hh,mm;
int cal(int hh,int mm) //Calculate how far the current time is from 9pm
{
int s=21*60;
return s-hh*60-mm;
}

int main()
{
cin>>hh>>mm;
cin>>m>>k>>q>>p;
int tot=cal(hh,mm);
tot=max(0,tot)*k; //How much anger does a girlfriend have to increase by 9 p.m.
double c1=q*0.75*x1;
double ans=q*x2;
ans=min(c1,ans);	//The minimum of the two is the answer

printf("%.4lf",ans);
return 0;
}
```

2. Summon the Dragon
You have n types of cards, and the number of cards of type i is c[i]. In addition, there is a special card: candle dragon card, referred to as r card. Its number is m. You can use one of each type of card to form a set of cards, or you can use one r card and one other card other than a certain kind of card to form a set of cards, so that you can summon Shenlong, a set of cards A dragon can be summoned. For example, when n=3, there are 4 valid decks: {1,2,3}, {r,2,3}, {1,r,3}, {1,2,r}. Given n, m and c[i], your task is to make as many decks as possible. Each card can only be used in one set of cards at most (there can be cards that are not used).

```#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m;
ll c;
bool check(int x)
{
ll t = 0;
for (int i = 1; i <= n; i++)
if (c[i] < x)
t += x - c[i];
return t <= x && t <= m;
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> c[i];
ll l = 0, r = 1e9;
while (l <= r)
{
ll mid = (l + r) >> 1;
if (check(mid))
l = mid + 1;
else
r = mid - 1;
}
cout << r << endl;
return 0;
}
```

3. Big promotion

The watermelon stand in front of Brother Xiaoma has started a big promotion. The sign next to the booth read: "Buy x watermelons get Y free watermelons". That is to say, for every X watermelon you buy, the stall owner will give you Y free watermelons.

```#include<bits/stdc++.h>

using namespace std;

int main( )
{
int a,b,c,d;
cin>>a>>b>>c>>d;
int money=d/(a+b)*c*a;
int surplus=d%(a+b);
if(surplus>a) money+=a*c;
else money+=surplus*c;
cout<<money<<endl;
return 0;
}
```

4. Orbital detection
The clever little brother soon discovered that there are many cases where the three circular orbits are tangent to each other, including the case of tangent to the same point and the case of tangent to three different points. The cases of tangent at three different points are also subdivided into two types. Type 1 is circumscribed to each other, and type 2 is that the large circle contains two small circles, which are inscribed with the two small circles respectively, and the two small circles are circumscribed with each other. The figure below shows an example of Type 2.

```#include<bits/stdc++.h>

using namespace std;
bool cmp(vector<int>a ,vector<int> b){
return a>b;
}

int distance(vector<int> a,vector<int> b){
return sqrt(pow(a-b,2)+pow(a-b,2));
}
bool judge(vector<vector<int>> circles){
if(circles!=circles+circles)
return false;
if(distance(circles,circles)!=distance(circles,circles)+distance(circles,circles))
return false;
return true;

}
int main( )
{

vector<vector<int>> circles(3,vector<int>(3));
for(int i=0;i<3;i++){
for(int j=0;j<3;j++)
cin>>circles[i][j];
}
sort(circles.begin(),circles.end(),cmp);
//for(auto it: circles)
//   cout<<it<<endl;
cout<<(judge(circles)?"YES":"NO")<<endl;

return 0;
}
```

Tags: Algorithm C++

Posted by milind24 on Sun, 13 Nov 2022 02:38:47 +0530