首页 > 其他分享 >牛客周赛47 (待补F和思路)

牛客周赛47 (待补F和思路)

时间:2024-06-16 21:10:56浏览次数:9  
标签:10 const 待补 47 ll cin long 牛客 int

比赛链接:牛客周赛47


赛时感受

       又是一场思维题,应该只有EF有点算法,E需要使用快速幂和取余,F做不出,C卡了我一下,D写完了,E不写完一半又回来看C才做掉的,E也卡了很久虽然鸽巢原理想到了,但是没想到被卡在取余问题上,一开始没想出来,去做F然后做了半个小时发现做不掉,又回来在E上做功夫。


A

思路

       

代码

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 10;

ll n[N];
int main() {
  int a, b, c, d, e;
  cin >> n[1] >> n[2] >> n[3] >> n[4] >> n[5];

  sort(n + 1, n + 1 + 5);
  if ((n[3] == n[5] && n[1] == n[2]) || (n[1] == n[3] && n[4] == n[5])) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

B

思路

       

代码

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 10;

ll n;
int main() {
  cin >> n;

  string s[N];
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < 26; i++) {
    int flag = 0;
    for (int j = 1; j <= n; j++) {
      if (s[j].find('a' + i) == -1) {
        flag = 1;
        break;
      }
    }
    if (flag)
      continue;
    cout << (char)('a' + i);
    break;
  }  

  return 0;
}

C

思路

       

代码

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 10;

ll n, a[N], sum, maxn;
int main() {
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    maxn = max(maxn, a[i]);
  }

  if (sum % 2 == 0) {
    if (n == 2) {
      if (a[1] == a[2]) {
        cout << 0 << endl;
      } else {
        cout << 1 << endl;
      }
    } else if (sum <= maxn * 2 || (sum - maxn == n - 1)) {
      cout << 1 << endl;
    } else if (maxn == 1) {
      cout << 0 << endl;
    } else {
      cout << n << endl;
    }
  } else {
    if (sum <= maxn * 2 && maxn != 1) {
      cout << 1 << endl;
    } else {
      cout << n << endl;
    }
  }

  return 0;
}

D

思路

       

代码

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 10;

ll n, a[N] = { 1, 2, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 25, 26, 28, 29 };
int main() {
  int t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    cout << ((n - 1) / 18) * 30 + a[((n - 1) % 18)] << endl;
  }

  return 0;
}

E

思路

       分类讨论横轴对称,纵轴对称和中心堆成,结果为横轴对称 + 纵轴堆成 - 中心对称,因为中心堆成的部分都包含于横轴对称和纵轴堆成,若不减去则会计算两次。
       纵轴对称的情况可能为:n为奇数时,纵轴所在的元素及其左边的元素只能选择

代码

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
ll pow(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y & 1) {
      res *= x;
      res %= mod;
    }
    y >>= 1;
    x *= x;
    x %= mod;
  }
  return res;
}
int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 4 << endl;
    return 0;
  }
  ll res = (((pow(4ll, n / 2) * (n % 2 == 1 ? 2ll : 1ll)) % mod + pow(4ll, n)) % mod - pow(2ll, ((n + 1) / 2)) + mod);
  cout << (res % mod);
  return 0;
}

F

思路

       

代码


标签:10,const,待补,47,ll,cin,long,牛客,int
From: https://www.cnblogs.com/againss/p/18251238

相关文章

  • 牛客周赛 Round 47
    时刻多日没打竟然退步了 A.小红的葫芦思路:五个元素三个相同另外两个相同可以通过数组排序写也可以map等等方法很多Code:#include<bits/stdc++.h>usingnamespacestd;map<int,int>mp;intmain(){ios::sync_with_stdio(false);cin.tie(0);......
  • GH2747高温合金进口板弹性模量与蠕变性能
    通过对GH2747高温合金的材料特性和性能进行详细的描述和分析,提供了该合金在高温环境下的弹性模量和蠕变性能的关键参数,为其在航空航天、能源等领域的应用提供了重要参考。弹性模量(ElasticModulus):GH2747高温合金的弹性模量是衡量其在受力作用下回复原状能力的重要参数之一。......
  • GH2747高温合金化学成分、物理性能及机械性能
    GH2747高温合金是一种在极端高温环境下表现出色的材料,广泛应用于航空航天、燃气轮机、核能及化工等领域。本文将详细分析GH2747高温合金的关键参数及其在不同应用中的性能表现,旨在为工程师和制造商提供全面的技术参考。1.化学成分GH2747高温合金主要成分包括:镍(Ni):约75%钴(Co):......
  • 代码随想录算法训练营第六十天 | 647. 回文子串、516.最长回文子序列
    647.回文子串文字讲解:代码随想录视频讲解:动态规划,字符串性质决定了DP数组的定义|LeetCode:647.回文子串_哔哩哔哩_bilibili解题思路1.dp[i][j]     [i,j]子串是否是回文的      是则返回true,不是则返回false2.递推公式if(s[i]==s[j])   ......
  • 5.30安卓开发日记47
    ① 、实现的功能为对错题信息的增删改查Ⅰ、主页面 Ⅱ、错题录入 Ⅲ、错题查询(可根据题目搜索) Ⅳ、错题修改 Ⅴ、错题删除(选中行后右键选择删除) Ⅵ、显示详细信息 ......
  • DreamJudge-1478-喝饮料
    1.题目描述TimeLimit:1000msMemoryLimit:256mb商店里有n中饮料,第i种饮料有mi毫升,价格为wi。小明现在手里有x元,他想吃尽量多的饮料,于是向你寻求帮助,怎么样买才能吃的最多。请注意,每一种饮料都可以只买一部分。输入输出格式输入描述:有多组测试数据。第一行输入两......
  • 代码随想录 算法训练营 day10 leetcode232 用栈实现队列 Leetcode225 用队列实现栈 Le
    Leetcode232用栈实现队列题目链接讲解用两个栈实现队列每次需要出队列或者查看队头元素时,将输入栈的所有元素放到输出栈classMyQueue{Stack<Integer>stackIn;Stack<Integer>stackOut;publicMyQueue(){stackIn=newStack<>();//负责进......
  • 算法训练(leetcode)第九天 | 232. 用栈实现队列、225. 用队列实现栈、20. 有效的括号、1
    刷题记录232.用栈实现队列225.用队列实现栈20.有效的括号1047.删除字符串中的所有相邻重复项232.用栈实现队列leetcode题目地址考察栈与队列之间的特性。栈:后进先出(先进后出)——FILO。队列:先进先出——FIFO。所以使用两个栈模拟队列,分别为in和out。当入队新......
  • Codeforces Round 947 (Div. 1 + Div. 2)
    发现今天做不了一点题,遂来补以前的比赛。B.378QAQandMocha'sArray秒了。排序,取最小的数记为\(x\),再取最小的无法被\(x\)整除的数记为\(y\),如果仍然存在无法被\(y\)整除的数,则无解。C.ChamoandMocha'sArray容易想到一个结论:如果一个数比它左边或右边的数小,那么......
  • 牛客小白月赛96(待补思路和F)
    比赛链接:牛客小白月赛96赛时感受    赛时在前面卡的时间有点长,C题没开longlongwa了n发,D题没考虑负数又wa了n发,然后来写E的时候时间就不长了,匆忙写一次交一发。A思路    题解#include<bits/stdc++.h>usingnamespacestd;constintN=1e5+10;#......