1. Buy gifts

Brother Xiaoma is in love! But he prefers to play pie, and when he finishes playing pie, he finds that it is already x points x points, because he has not responded to his girlfriend's news, his girlfriend's current anger value is to compensate his girlfriend, he If you are going to buy a gift for your girlfriend, your girlfriend's anger value will rise every minute, and the little brother can buy a gift at any time (assuming that buying a gift does not take time), each gift costs yuan, which can offset one anger value, and the store starts discounting from 21:00, please help Xiaoma to find the minimum amount to spend to make his girlfriend relieved (girlfriend relieved means her anger value is less than or equal to 0), and ensure that the data given in the question are all legitimate.

#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. int x1=ceil(1.0*(m+tot)/p); //All buy gifts after 9pm buy at least a few double c1=q*0.75*x1; int x2=ceil(1.0*m/p); //Buy at least a few gifts at the beginning 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[55]; 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[2]>b[2]; } int distance(vector<int> a,vector<int> b){ return sqrt(pow(a[0]-b[0],2)+pow(a[1]-b[1],2)); } bool judge(vector<vector<int>> circles){ if(circles[0][2]!=circles[1][2]+circles[2][2]) return false; if(distance(circles[1],circles[2])!=distance(circles[0],circles[1])+distance(circles[0],circles[2])) 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[2]<<endl; cout<<(judge(circles)?"YES":"NO")<<endl; return 0; }