3月13

披星戴月的贾维斯
C/C++领域新星作者
2023-03-13 16:53:52

1、裁纸刀

#include <iostream>
using namespace std;
int main()
{
  cout<< 4+(20-1)+(22-1)*20 << endl;
  return 0;
}

2、刷题统计

#include <iostream>
using namespace std;
typedef long long LL;
int main()
{
  LL a, b ,n;
  cin >> a >> b >> n;
  LL c = 5 * a, d = 2 * b;
  LL res  = 0;
  if(n <= c + d)
  {
    if(n >= c) 
    {
      res += 5;
      if(n - (c) > b) 
      {
        res += 2;
      }
      else res += 1;
    }
    else 
    {
      if(n % a != 0) res = (n / a) + 1;
      else res = n / a;
    }
  }
  else
  {
    LL h = n % (c + d);
    res += (n / (c + d)) * 7;
    if(h >= c) 
    {
      res += 5;
      if((h - c) > b) 
      {
        res += 2;
      }
      else res += 1;
    }
    else 
    {
      if(h % a != 0) res += (h / a) + 1;
      else res += h / a;
    }
  }
  cout <<  res << endl;
  return 0;
}

3、修建灌木

#include <iostream>
using namespace std;
int n;
const int N = 1e4 + 10;
int a[N] = {0};
int main()
{
  cin >> n;
  for(int i = 1; i <= n/2; i++)
  {
    a[i] = 2 * (n - i);
  }
  if(n % 2 != 0)
  {
    a[(n / 2) + 1] = 2 * (n / 2);
    for(int i = (n / 2) + 2; i <= n; i++)
    {
      a[i] = a[n + 1 - i];
    }
  }
  else
  {
    for(int i = (n / 2) + 1; i <= n; i++)
    {
      a[i] = a[n - i + 1];
    }
  }
  for(int i = 1; i <= n; i++)
  {
    cout << a[i] << endl;
  }
  return 0;
}

4、k倍区间

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 100010;
typedef long long LL;
LL s[N], cnt[N];
int n, k;
int main ()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &s[i]);
        s[i] += s[i - 1];
    }
    cnt[0] = 1;
    LL res = 0;
    for(int i = 1; i <= n; i++)
    {
        res += cnt[s[i] % k];
        cnt[s[i] % k]++;
    }
    
    printf("%lld\n", res);
    return 0;
}

 

...全文
21 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,854

社区成员

发帖
与我相关
我的任务
社区描述
和众多高校算法内卷分子,一起学习和交流算法那。浓郁的算法交流氛围,拒绝躺平,有效内卷。加入我们,私信我拉你入核心内卷群。
算法数据结构leetcode 个人社区
社区管理员
  • 执 梗
  • Dream-Y.ocean
  • ღCauchyོꦿ࿐
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

 刷题!

试试用AI创作助手写篇文章吧