零点工作室暑假集训(AtCoder--ABC234)

A - Weird Function

题意:我们定义一个函数 f:
f(x) = x^2 + 2x + 3.
给定一个整数 t,求 f(f(f(t) + t) + f(f(t))) 的值。
这里保证答案是不大于 2×10^9 的整数。

思路:直接带公式即可

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 100010, INF = 0x3f3f3f3f, Mod = 1e9 + 7;

int x;

void solved()
{
    cin >> x;
    int a = x * x + 2 * x + 3 + x;
    int b = x * x + 2 * x + 3;
    int c = a * a + 2 * a + 3;
    int d = b * b + 2 * b + 3;
    int ans = c + d;
    
    cout << ans * ans + 2 * ans + 3;
     
    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //int t;
    //cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

B - Longest Segment

题意:给定平面上的N个点,第i个点的坐标为(x_i, y_i)。要找到连接这些点中两个点的最大线段长度。

思路: 考察了数学:两点距离公式(欧氏距离),直接O(n ^ 2)

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 110, INF = 0x3f3f3f3f, Mod = 1e9 + 7;

int n;
int x[N], y[N];

void solved()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
            cin >> x[i] >> y[i];
    }
    
    double d = 0.0;
    
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 1; j <= n; j ++)
        {
            double tmp = sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));
            d = max(d, tmp);
        }
    }
    printf("%.6f\n", d);

     
    return ;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //int t;
    //cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

C - Happy New Year!

题意: 在十进制中由0和2组成的正整数中,找到第K小的整数。

思路:本质就是计算 k 的二进制表示,注意把 ’1‘ 变成 ’2‘,由于数据很大,所以得开long long

AC代码

#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
#define xx first
#define yy second
#define sz size

typedef long long LL;
typedef pair<int , int> PII;
typedef pair<LL , LL> PLL;
 
const int N = 110, INF = 0x3f3f3f3f, Mod = 1e9 + 7;

LL k;

void solved()
{
    cin >> k;
    
    string tmp = "";
    while(k >= 1)
    {
        if(k % 2 == 0)
        {
            tmp = '0' + tmp;
        }
        else
        {
            tmp = '2' + tmp;
        }
        
        k /= 2;
    }
    
    cout << tmp << endl;
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    //int t;
    //cin >> t;
 
    while(t -- )
    {
        solved();
    }
 
    return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值