2022-03-10每日刷题打卡

一、AcWing 1221. 四平方和

1. 问题描述

img

2. 问题解决

#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>

#define x first
#define y second

using namespace std;

typedef pair<int, int> PII;

const int N = 2500010;

int n, m;
unordered_map<int, PII> S;

int main()
{
    cin >> n;

    for (int c = 0; c * c <= n; c ++ )
        for (int d = c; c * c + d * d <= n; d ++ )
        {
            int t = c * c + d * d;
            if (S.count(t) == 0) S[t] = {c, d};
        }

    for (int a = 0; a * a <= n; a ++ )
        for (int b = 0; a * a + b * b <= n; b ++ )
        {
            int t = n - a * a - b * b;
            if (S.count(t))
            {
                printf("%d %d %d %d\n", a, b, S[t].x, S[t].y);
                return 0;
            }
        }

    return 0;
}

二、蓝桥杯 2017 分巧克力

1. 问题描述

img

2. 问题解决

#include <iostream>

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;

int h[N], w[N];
int n, k;

bool check(int len)
{
    int sum = 0;
    for(int i = 1; i <= n; i++)
        sum += (h[i] / len) * (w[i] / len);
    
    if(sum < k) return false;
    else return true;
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i ++ )
        scanf("%d %d", &h[i], &w[i]);
    
    int l = 0, r = 1e5;
    
    while(l < r)
    {
        int mid = (l + r + 1) >> 1;
        
        if(check(mid)) l = mid;
        else r = mid - 1;
        
    }
    
    cout << r << endl;
    
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue.js是一种流行的JavaScript框架,用于构建用户界面。要实现每日打卡功能,你可以按照以下步骤进行: 1. 创建一个Vue组件,用于显示打卡相关的信息和按钮。 2. 在组件的data属性中定义一个变量,用于记录打卡状态,比如isPunched。 3. 在组件的methods属性中定义一个方法,用于处理打卡逻辑。当用户点击打卡按钮时,该方法会被调用。 4. 在方法中,你可以使用JavaScript的Date对象获取当前日期,并将其与用户上次打卡的日期进行比较。如果日期不一致,表示用户需要进行打卡操作。 5. 如果需要保存用户的打卡记录,你可以使用浏览器的本地存储(localStorage)或者发送请求到服务器来保存数据。 下面是一个简单的示例代码: ```html <template> <div> <p v-if="isPunched">今日已打卡</p> <p v-else>今日未打卡</p> <button @click="punch">打卡</button> </div> </template> <script> export default { data() { return { isPunched: false }; }, methods: { punch() { const lastPunchDate = localStorage.getItem('lastPunchDate'); const currentDate = new Date().toLocaleDateString(); if (lastPunchDate !== currentDate) { // 执行打卡逻辑 // ... // 更新打卡状态和日期 this.isPunched = true; localStorage.setItem('lastPunchDate', currentDate); } } } }; </script> ``` 在上面的示例中,我们使用了Vue的条件渲染指令(v-if和v-else)来根据打卡状态显示不同的文本。当用户点击打卡按钮时,会调用punch方法进行打卡逻辑的处理。我们使用localStorage来保存用户的上次打卡日期,并在下次打卡时进行比较。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值