3月13

披星戴月的贾维斯 披星戴月的贾维斯 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

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;
}

 

...全文
评论
收藏 已收藏
分享
返回顶部
披星戴月的贾维斯
披星戴月的贾维斯 新星创作者: C/C++技术领域 新星创作者: C/C++技术领域
高校算法学习社区 51,723 成员 6,062 内容