题意:\(f(x,m)\)表示\(x\ mod\ m\),\(A_{1}=1\),而\(A_{n+1}=f(A^{2}_{n},M)\),求\(\sum^{n}_{i=1}A_{i}\). 题解:多算几个,会有一个循环节,直接模拟就好了. 代码: ll n,x,m; ll mp[N]; vector<ll> a; int main() { //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); scanf("%lld %lld %l…
比赛链接:https://atcoder.jp/contests/abc179/tasks A - Plural Form 题意 给出一个由小写字母组成的单词,如果单词以 $s$ 结尾,在单词的末尾加上 $es$,否则在单词的末尾加上 $s$ . 代码 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin &g…
D - Xor Sum 2 Time limit : 2sec / Memory limit : 1024MB Score : 500 points Problem Statement There is an integer sequence A of length N. Find the number of the pairs of integers l and r (1≤l≤r≤N) that satisfy the following condition: Al xor Al+1 xor …
题意:有\(2^n\)个人站成一排比赛,刚开始每个人都和自己右边的人进行比赛,赢得人晋级下一轮(下标的小的在前面),不断重复这个过程,问最后拿到第二名的人的编号. 题解:根据题意,可以用vector直接模拟这个过程. 代码: #include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back #define me memset #define rep(a,b,…
题意:给你一个数字\(n\)和\(k\)个区间,\(S\)表示所有区间的并的集合,你目前在\(1\),每次可以从集合中选择一个数字向右移动,问有多少种方法从\(1\)走到\(n\). 题解:我们从1开始遍历,\(dp[i]\)表示走到目前走到\(i\)的方案数,再去遍历每一个集合,用\(dp[i]\)更新所有\([i+l[j],i+r[j]]\)中的点,而遍历区间我们可以用差分来\(O(n)\)的运行出来. 代码: int n,k; int l[N],r[N]; ll dp[N]; int ma…
预处理即可 我们要找的是 (f[i] - f[j]) % k == i - j 移项可得 f[i] - i = f[j] - j 在 i - j <= k 的条件下 因此题目变成了,对于每个右端点,在它的左边 k - 1 个有多少个满足 f[i] - i = f[j] - j f[i] 是前缀和数组 AC_CODE #include <map> #include <iostream> #define LL long long using namespace std; cons…
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E869120's and square1001's 16-th birthday is coming soon.Takahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces. E869…
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) oth…
AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.Here, a correct bracket sequence is def…
人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We have A balls with the string S written on each of them and B balls with the string T written on each of them. From these balls, Takahashi chooses one…