首页 > 其他分享 >HHKB Programming Contest 2023(AtCoder Beginner Contest 327)

HHKB Programming Contest 2023(AtCoder Beginner Contest 327)

时间:2023-11-04 22:33:07浏览次数:35  
标签:AtCoder false Beginner Contest int rep cin true

HHKB Programming Contest 2023(AtCoder Beginner Contest 327)

A - ab

int main() {
    IOS;
    string s;
    cin >> n >> s;
    bool f = false;
    for (int i = 1; i < n; ++i)
        if (s[i - 1] == 'a' && s[i] == 'b') f = true;
        else if (s[i] == 'a' && s[i - 1] == 'b') f = true;
    cout << (f ? "Yes" : "No");
    return 0;
}

B - A^A

int main() {
    IOS;
    cin >> n;
    int f = -1;
    for (int i = 1, j = 1; true; ++i, j = 1) {
        ll s = 1;
        for (; j <= i && s <= n / i; ++j) s *= i;
        if (j <= i || s > n) break;
        if (s == n) { f = i; break; } 
    }
    cout << f;
    return 0;
}

C - Number Place

int a[9][9], f[9];

int main() {
    IOS;
    rep (i, 0, 8) rep (j, 0, 8) cin >> a[i][j], --a[i][j];
    bool g = true;
    rep (i, 0, 8) {
        memset(f, 0, sizeof f);
        rep (j, 0, 8) {
            f[a[i][j]] |= 1, f[a[j][i]] |= 2;
            f[a[i / 3 * 3 + j / 3][i % 3 * 3 + j % 3]] |= 4;
        }
        rep (j, 0, 8) if (f[j] != 7) g = false;
    }
    cout << (g ? "Yes" : "No");
    return 0;
}

D - Good Tuple Problem

判断二分图

int h[N], to[M], ne[M], tot;
int a[M >> 1], color[N];

void add(int u, int v) {
    ne[++tot] = h[u];
    to[h[u] = tot] = v;
}

bool dfs(int x, int c) {
    color[x] = c;
    for (int i = h[x], y = to[i]; i; y = to[i = ne[i]]) {
        if (color[y] == c) return false;
        if (!color[y] && !dfs(y, -c)) return false;
    }
    return true;
}

int main() {
    IOS;
    cin >> n >> m;
    rep (i, 1, m) cin >> a[i];
    rep (i, 1, m) cin >> k, add(a[i], k), add(k, a[i]);
    bool f = true;
    rep (i, 1, n) {
        if (color[i]) continue;
        if (!dfs(i, 1)) { f = false; break; }
    }
    cout << (f ? "Yes" : "No");
    return 0;
}

E - Maximize Rating

dp

$x_k = \textstyle \sum_{i=1}^{k} 0.9^i$
$y_k = \frac{1200}{ \sqrt{k} } $
$d_k = max(\textstyle \sum_{i=1}^{k} 0.9^i \times Q_i)$
$ans = max(\frac{d_k}{x_k} - y_k)$

int a[N];
double x[N], y[N], d[N];

int main() {
    IOS;
    cin >> n; x[0] = 0, y[0] = 1;
    double ans = -1500, z = 1;
    rep (i, 1, n) {
        cin >> a[i], x[i] = z + x[i - 1], z *= 0.9, y[i] = 1200 / sqrt(i);
        d[i] = -1500;
        per (j, i, 1) {
            d[j] = max(d[j], d[j - 1] * 0.9 + a[i]);
            ans = max(ans, d[j] / x[j] - 1200 / y[j]);
        }
    }
    cout << precision(6) << ans;
    return 0;
}

标签:AtCoder,false,Beginner,Contest,int,rep,cin,true
From: https://www.cnblogs.com/2aptx4869/p/17809933.html

相关文章

  • Atcoder Beginner Contest 327 解题报告
    AtcoderBeginnerContest327HintsD$\quad$这个定义……看起来这么熟悉?E$\quad$固定$k$试试?F_1$\quad$扫描线?F_2$\quad$区间加,区间$\max$,咋维护?A直接查找\(\texttt{ab}\)和\(\texttt{ba}\)即可。intn;strings;voidSolve(intCASE){ cin>>n>>s; pu......
  • HHKB Programming Contest 2023(AtCoder Beginner Contest 327)
    HHKBProgrammingContest2023(AtCoderBeginnerContest327)A.ab解题思路:模拟即可。代码:#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;voidsolve(){intn;cin>>n;strings;cin>>s;for(inti=0......
  • AtCoder Beginner Contest 327
    A-ab(abc327A)题目大意给定一个字符串\(s\),问是否包含ab或ba。解题思路遍历判断即可。神奇的代码#include<bits/stdc++.h>usingnamespacestd;usingLL=longlong;intmain(void){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);i......
  • Atcoder Grand Contest 016
    给我贺完了?A-Shrinking给定一个串\(s\),每次可以进行如下操作:记串长为\(n\).构造长为\(n-1\)的串\(s'\),满足\(s'_i\)为\(s_i\)或\(s_{i+1}\),令\(s\leftarrows'\).问使\(s\)中所有字符相同的最小操作次数。\(|s|\le100\).按照题意模拟即可,时间复杂度......
  • AtCoder Beginner Contest 326 (ABC326)
    A.2UP3DOWN直接模拟即可。CodeB.326-likeNumbers枚举,每次拆除百、十、个位,再判断。CodeC.PeakDescription数字线上放置了\(N\)个礼物。第\(i\)个礼物放置在坐标\(A_i\)处。可以在数轴上选择长度为\(M\)的半开区间\([x,x+M)\),并获得其中包含的所有礼物。求:......
  • AtCoder Beginner Contest 224 H Security Camera 2
    洛谷传送门AtCoder传送门直接糊一手线性规划对偶板板。要求:\[\min\sumA_il_i+\sumB_ir_i\]\[\foralli,j,l_i+r_j\geC_{i,j}\]\[l_i,r_i\ge0\]\[l_i,r_i\in\mathbb{Z}\]可以证明\(l_i,r_i\)为整数的限制可以去掉,因为取到最优解时\(l_i,r_i\)一......
  • AtCoder Beginner Contest(abc) 314
    B-Roulette难度:⭐题目大意有一个猜数字的游戏,有n个人参加,每人都猜了若干个数;最后给出答案数字;在所有猜中数字的人中输出猜数数量最少的人的编号;(可能不止一个);解题思路数据不大,暴力即可;神秘代码#include<bits/stdc++.h>#defineintlonglong#def......
  • AtCoder Beginner Contest 326 F
    F-RobotRotation一句话不开LL,见祖宗感谢大佬,和洛谷上的题解上面已经将的很清楚了,但是如果你跟我一样一开始看不懂他们的代码,那么这篇可能为你解惑点击查看代码#include<bits/stdc++.h>usingnamespacestd;#defineLLlonglong#defineintLL//LL!map<LL,LL>ma;......
  • AtCoder Beginner Contest(abc) 312
    B-TaKCode难度:⭐题目大意题目定义一种矩阵X:该矩阵的是一个长度为9的由黑白色块组成正方形矩阵;该矩阵的左上角和右下角都是一个3*3的黑色矩阵(总共18个),这两个黑色矩阵外面(边缘不算)包围一圈白色色块(总共14个);现在一个n*m的黑白矩阵,问这个大矩阵中有多少......
  • AT_abc326_e Revenge of "The Salary of AtCoder Inc." 题解
    AT_abc326_eRevengeof"TheSalaryofAtCoderInc."题解一道简单的概率论+动态规划题目(然而我赛时没看这道题题意有一个长度为\(n\)的序列\(A\)、一个\(n\)面骰子,掷若干次骰子,如果这一次掷骰子的点数小于等于上一次的点数,则结束。定义这若干次掷骰子的总的结果为,每次......