首页 > 其他分享 >Educational Codeforces Round 13

Educational Codeforces Round 13

时间:2023-01-07 11:56:03浏览次数:63  
标签:Educational return cout int 13 long Codeforces using include

Educational Codeforces Round 13

https://codeforces.com/contest/678
4/6:ABCD (1h)
前4题都很简单,E应该是个撞鸭dp但是我想不出来

A. Johny Likes Numbers

#include <bits/stdc++.h>

using namespace std;

int main () {
    int n, k;
    cin >> n >> k;
    int cnt = (n + k - 1) / k * k;
    if (n % k == 0) cnt += k;
    cout << cnt;
}

B. The Same Calendar

累加天数和,余数与当年相同且同为/同不为闰年即可。

#include <bits/stdc++.h>

using namespace std;
int n, sum;

bool isLeap (int x) {
    if (x % 400 == 0)       return  true;
    if (x % 4 == 0 && x % 100)  return true;
    return false;
}

int main () {
    cin >> n;
    if (isLeap (n)) {
        sum += 366;
        for (int i = n + 1; ; i ++) {
            int dx = isLeap (i);
            sum += 365 + dx;
            //cout << i << ' ' << dx << ' ' << sum << ' ' << sum % 7 << endl;
            if (dx && sum % 7 == 2) {
                cout << i;
                break;
            }
        }
    }
    else {
        sum += 365;
        for (int i = n + 1; ; i++) {
            int dx = isLeap (i);
            sum += 365 + dx;
            //cout << i << ' ' << dx << ' ' << sum << ' ' << sum % 7 << endl;
            if (!dx && sum % 7 == 1) {
                cout << i;
                break;
            }
        }
    }
}

C. Joty and Chocolate

数学+简单容斥

#include <bits/stdc++.h>
#define int long long

using namespace std;
int n, a, b, p, q, cnta, cntb, cntab;

signed main () {
    cin >> n >> a >> b >> p >> q;
    cnta = n / a - (1 + a - 1) / a + 1;
    cntb = n / b - (1 + b - 1) / b + 1;
    int ab = (a * b) / __gcd (a, b);
    cntab = n / ab - (1 + ab - 1) / ab + 1;
    //cout << cnta << ' ' << cntb << ' ' << cntab << endl;
    cout << (cnta - cntab) * p + (cntb - cntab) * q + cntab * max (p, q);
}

//1-n里面有多少个x的倍数

D. Iterated Linear Function

复合函数推是式子:

\[A^nx+\frac{A^n-1}{A-1}B \]

除法那里要用逆元+注意特判 \(A=1\)

#include <bits/stdc++.h>
#define int long long

using namespace std;
const int p = 1e9 + 7;
int a, b, n, x;

int qmi(int a, int k) {
	int ans = 1;
	while (k) {
		if (k & 1)	ans = ans * a % p;
		k >>= 1;
		a = a * a % p;
	}
	return ans;
}

signed main () {
    cin >> a >> b >> n >> x;
    if (a == 1) {
        cout << (x + n % p * a % p * b % p) % p;
        return 0;
    }
    int da = qmi (a, n), inv = qmi (a - 1, p - 2);
    //cout << da;
    cout << (x % p * da + (da - 1) * inv % p * b) % p;
}

//A^n * x + (1-A^n)/(1-A) * B

E. Another Sith Tournament

EF待补

F. Lena and Queries

标签:Educational,return,cout,int,13,long,Codeforces,using,include
From: https://www.cnblogs.com/CTing/p/17032414.html

相关文章

  • Oracle数据恢复故障处理之启动报错:ORA-03113: end-of-file on communication channel
    lsnrctl启动实例startup报错ORA-03113:end-of-fileoncommunicationchannel $su-oracleStep1:Youneedtolookatthealertlog.Itisn'tin/var/logas......
  • Codeforces Round #648 (Div. 2) A-D,补E
    A.MatrixGame题意:一个矩阵初始状态有些位置是1表示该位置对应的行和列都已经被占用。现在两人轮流选一个未被占用的位置标记,A是先手,谁动不了了谁就输了,输出赢家。......
  • Codeforces CF255C Almost Arithmetical Progression
    链接难度:\(1500\)有一个序列\(b_{1\simn}\)。你需要从中选出一个长度最长的子序列\(p_{1\simk}\),使其满足\(p_1=p_3=...=p_{\lceil\frac{k}{2}\rceil-1},p_2=p_4=......
  • 2023.1.6 (Codeforces Round #842 (Div. 2))
    A.GreatestConvexLinkhttps://codeforces.com/contest/1768/problem/ADescription求出最大的\(x(1\leqx<k)\),使得\(x!+(x-1)!\)是\(k\)的倍数。Soluti......
  • Codeforces Round #842 (Div. 2)
    CodeforcesRound#842(Div.2)https://codeforces.com/contest/1768好困,放完代码就跑路。A.GreatestConvex#include<bits/stdc++.h>usingnamespacestd;void......
  • Codeforces Round #842 (Div. 2)
    Preface唉现在这是是做稍微难点的SB题(指Div2正常场的CD难度)总是要犯病因此Rating上不去不说,比赛的时候连EF题面都没机会看一眼这场先是C交上去忘记本机调试的时候把数组......
  • Codeforces Round 842
    目录写在前面ABCDE写在最后写在前面仁王真好玩大太刀真好玩下辈子我还要玩大太刀[](https://pic.imgdb.cn/item/63b7fdb4be43e0d30ec2dccd.jpg)顺带吐槽一下,这什么排......
  • Codeforces Round #842 (Div. 2)
    题目链接A核心思路:样例模拟出答案。#define_CRT_SECURE_NO_WARNINGS#include<iostream>#include<cstring>#include<algorithm>#include<vector>#include<bits/std......
  • Codeforces Round #842 (Div. 2) A-D
    比赛链接A题意给一个数\(k\)找到最大的\(x\),满足\(1\leqx<k\)且\(x!+(x-1)!\)是\(k\)的倍数。题解知识点:数学。猜测\(x=k-1\),证明\((k-1)!+(k-......
  • 第13届蓝桥杯javaB组
    第13届蓝桥杯javaB组试题A星期计算问题描述已知今天是星期六,请问\(20^{22}\)天后是星期几?注意用数字\(1\)到\(7\)表示星期一到星期日。思路一因为每七天一个......