SDUT 2022 Spring Team Contest(for 21) - 3

C - Cardboard Containericon-default.png?t=M276https://vjudge.net/problem/Kattis-cardboardcontainer

c题是给定n个 棱长为1的立方体,来摆成一大的长方体(包括正方体),求所有可能摆成的长方体的表面积最小值。

暴力枚举其中两条边,计算出第三条边(因为最小单位是1,所以必须整除)

#include <iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<math.h>
#include<map>
#define TLE std::ios::sync_with_stdio(false)
using namespace std;
typedef pair<int, int>pii;
typedef pair<int,pii>PII;
const int INF = 0x3f3f3f3f;
const int N = 5e5 + 10;
int ans = INF;
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= sqrt(n); i++)//枚举道sqrt(n)即可
    {
        for (int j = 1; j <= i; j++)
        {
            if (n % (i * j) == 0)
            {
                int k = n / (i * j);
                ans = min(ans, 2 * (i * j + i * k + k * j));
            }
        }
    }
    cout << ans;
    return 0;
}

J - Janitor Troublesicon-default.png?t=M276https://vjudge.net/problem/Kattis-janitortroubles

已知四边形四条边求四边形最大面积的问题根据海伦公式求即可 

  

 

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    double p = (a + b + c + d) / 2;
    printf("%.15f\n", sqrt((p - a) * (p - b) * (p - c) * (p - d)));
    return 0;
}

F - Financial Planningicon-default.png?t=M276https://vjudge.net/problem/Kattis-financialplanning

 二分答案+贪心,注意INF要开1e9*10,0x3f3f3f3f是wa的

#include<bits/stdc++.h>
#define TLE ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
const int INF = 1e9 * 10;
const int N = 1e5 + 100;
ll n, m;
struct node
{
    ll v, w;
}a[N];
bool check(ll x)
{
    ll now=0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i].v * x- a[i].w >0 )
        {
            now += a[i].v * x - a[i].w;
            if (now >= m)return true;
        }
    }
    return false;
}
int main()
{
    TLE;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].v >> a[i].w;
    }
    ll l = 0, r = INF;
    ll ans = 0;
    while (l < r)
    {
        ll mid = (l + r)/2;
        if (check(mid))r = mid;
        else l = mid+1;
    }
    cout << r << endl;
    return 0;
}

 g题未完待续

 

 

 

 

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值