Educational Codeforces Round 104 (Rated for Div. 2)(VP)(寒假ACM模拟赛2)

2024-01-06 15:52

本文主要是介绍Educational Codeforces Round 104 (Rated for Div. 2)(VP)(寒假ACM模拟赛2),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

VP时间

A.找到最小,计算最小有几个

n-cnt;

1.ac

B.结论

模拟会超时

n&1:

n/2;相遇A继续走,B跳两格到n/2+1(n/2-1->n/2+1)

k<n/2就直接输出

n>k>n/2输出k+1

模拟一下 1234,12345

!n&1不会改变位置,直接输出k%n

n&1 找什么时刻会发现冲突

每一个周期冲突2次,

C.

偶数队伍就需要0

奇数队伍就1,-1,1,-1交替

D.

消C

a=sqrt(2*b+1);

c=b+1;

找范围暴力算

b<=n

a<=sqrt(2*n+1);

c<=n-1

n=1e9

min(n,1e5+9);

枚举a

!(pow(a,2)-1%2)ans++;

题解

A.
 

// Problem: A. Arena
// Contest: Codeforces - Educational Codeforces Round 104 (Rated for Div. 2)
// URL: https://codeforces.com/group/RAx5fiilkP/contest/1487/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void solve() {int n;cin>>n;for(int i=1;i<=n;i++){cin>>a[i];}int mn=INF;for(int i=1;i<=n;i++){mn=min(mn,a[i]);}int cnt=0;for(int i=1;i<=n;i++){if(mn==a[i]){cnt++;}}cout<<n-cnt<<'\n';}int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int q;cin >> q;while (q--) {solve();}return 0;
}

B.

根据行动路线可以画一个环

偶数环 (n=4)可以发现它们不会相遇,在k时刻时cout<<(k%n?k%n:0)<<'\n'; or (k-1)mod n+1

k==n时 nmodn=0;不正确 (故k-1)

奇数环 (n=5)可以发现相遇周期(t=(n-1/2))就是走k步后又多走(k/(t))步,防止(k==0)

因此cout<<(k-1+(k-1/(t)))%n+1<<'\n';

// Problem: B. Cat Cycle
// Contest: Codeforces - Educational Codeforces Round 104 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1487/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
void solve() {int n,k;cin>>n>>k;k--;//防止k==n cout<<0,之后补+1即可if(n&1){int t=(n-1)/2;cout<<(k+(k/t))%n+1<<'\n';}else{cout<<k%n+1<<'\n';}
}
int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int q;cin >> q;while (q--) {solve();}return 0;
}

C.

一共n个队

积分应该是kn分

每个队平均下来k分

胜负场x场

平局场y场

所以存在下面两个式子

x+y=\frac{n(n-1)}{2}

3x+2y=kn

得到

x=kn-n(n-1)

y=\tfrac{3n(n-1)}{2}-kn

要求平局数最小

故k最大

k\leqslant \frac{3(n-1)}{2}

当n为奇数时, k=\frac{3(n-1)}{2},x=\frac{n(n-1)}{2},y=0,每个队赢\frac{n-1}{2}

当n为偶数时,k=\frac{n-2}{2}+n-1,x=\frac{n(n-2)}{2},y=\frac{n}{2},每个队赢\frac{n-2}{2}

// Problem: C. Minimum Ties
// Contest: Codeforces - Educational Codeforces Round 104 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1487/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void solve() {int n;cin>>n;int cnt=n*(n-1)/2;if((n&1)){for(int i=1;i<=cnt;i++){if(i&1){cout<<1<<" ";}else{cout<<-1<<" ";}}}else{for(int i=0;i<n;i++){for(int j=i+1;j<n;j++){if(j-i<n/2){cout<<1<<" ";}else if(j-i==n/2){cout<<0<<" ";}else{cout<<-1<<" ";}}}}cout<<'\n';}int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int q;cin >> q;while (q--) {solve();}return 0;
}

D.

// Problem: D. Pythagorean Triples
// Contest: Codeforces - Educational Codeforces Round 104 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1487/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
int n;
bool check(int a,int b,int c){return c*c==a*a+b*b;
}
void solve() {cin>>n;ll ans=0;n=sqrt(2*n-1);for(int i=2;i<=min(n,100009);i++){if(((i*i)-1)%2==0){ans++;}}cout<<ans<<'\n';}int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int q;cin >> q;while (q--) {solve();}return 0;
}

这篇关于Educational Codeforces Round 104 (Rated for Div. 2)(VP)(寒假ACM模拟赛2)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/576835

相关文章

Python使用pynput模拟实现键盘自动输入工具

《Python使用pynput模拟实现键盘自动输入工具》在日常办公和软件开发中,我们经常需要处理大量重复的文本输入工作,所以本文就来和大家介绍一款使用Python的PyQt5库结合pynput键盘控制... 目录概述:当自动化遇上可视化功能全景图核心功能矩阵技术栈深度效果展示使用教程四步操作指南核心代码解析

Python模拟串口通信的示例详解

《Python模拟串口通信的示例详解》pySerial是Python中用于操作串口的第三方模块,它支持Windows、Linux、OSX、BSD等多个平台,下面我们就来看看Python如何使用pySe... 目录1.win 下载虚www.chinasem.cn拟串口2、确定串口号3、配置串口4、串口通信示例5

CSS模拟 html 的 title 属性(鼠标悬浮显示提示文字效果)

《CSS模拟html的title属性(鼠标悬浮显示提示文字效果)》:本文主要介绍了如何使用CSS模拟HTML的title属性,通过鼠标悬浮显示提示文字效果,通过设置`.tipBox`和`.tipBox.tipContent`的样式,实现了提示内容的隐藏和显示,详细内容请阅读本文,希望能对你有所帮助... 效

认识、理解、分类——acm之搜索

普通搜索方法有两种:1、广度优先搜索;2、深度优先搜索; 更多搜索方法: 3、双向广度优先搜索; 4、启发式搜索(包括A*算法等); 搜索通常会用到的知识点:状态压缩(位压缩,利用hash思想压缩)。

【C++】_list常用方法解析及模拟实现

相信自己的力量,只要对自己始终保持信心,尽自己最大努力去完成任何事,就算事情最终结果是失败了,努力了也不留遗憾。💓💓💓 目录   ✨说在前面 🍋知识点一:什么是list? •🌰1.list的定义 •🌰2.list的基本特性 •🌰3.常用接口介绍 🍋知识点二:list常用接口 •🌰1.默认成员函数 🔥构造函数(⭐) 🔥析构函数 •🌰2.list对象

usaco 1.2 Transformations(模拟)

我的做法就是一个一个情况枚举出来 注意计算公式: ( 变换后的矩阵记为C) 顺时针旋转90°:C[i] [j]=A[n-j-1] [i] (旋转180°和270° 可以多转几个九十度来推) 对称:C[i] [n-j-1]=A[i] [j] 代码有点长 。。。 /*ID: who jayLANG: C++TASK: transform*/#include<

Codeforces Round #240 (Div. 2) E分治算法探究1

Codeforces Round #240 (Div. 2) E  http://codeforces.com/contest/415/problem/E 2^n个数,每次操作将其分成2^q份,对于每一份内部的数进行翻转(逆序),每次操作完后输出操作后新序列的逆序对数。 图一:  划分子问题。 图二: 分而治之,=>  合并 。 图三: 回溯:

Codeforces Round #261 (Div. 2)小记

A  XX注意最后输出满足条件,我也不知道为什么写的这么长。 #define X first#define Y secondvector<pair<int , int> > a ;int can(pair<int , int> c){return -1000 <= c.X && c.X <= 1000&& -1000 <= c.Y && c.Y <= 1000 ;}int m

Codeforces Beta Round #47 C凸包 (最终写法)

题意慢慢看。 typedef long long LL ;int cmp(double x){if(fabs(x) < 1e-8) return 0 ;return x > 0 ? 1 : -1 ;}struct point{double x , y ;point(){}point(double _x , double _y):x(_x) , y(_y){}point op

Codeforces Round #113 (Div. 2) B 判断多边形是否在凸包内

题目点击打开链接 凸多边形A, 多边形B, 判断B是否严格在A内。  注意AB有重点 。  将A,B上的点合在一起求凸包,如果凸包上的点是B的某个点,则B肯定不在A内。 或者说B上的某点在凸包的边上则也说明B不严格在A里面。 这个处理有个巧妙的方法,只需在求凸包的时候, <=  改成< 也就是说凸包一条边上的所有点都重复点都记录在凸包里面了。 另外不能去重点。 int