全部题目跳转链接

A - The Miracle and the Sleeper

题意

给定\([l, r]\) 求出在这个区间内的两个数字ab的取模的最大值 (\(a \ge b\))

分析

上届确定 因此我们最大的取模的值就是 \(\frac {r}{2} + 1\)

但是这个值能取到的条件是\(\frac {r}{2} + 1 \ge l\)

如果上述条件不满足 很显然答案的区间是\([0, r-l]\)

AC_CODE

#include <bits/stdc++.h>
using namespace std; inline void solve() {
int l, r;
cin >> l >> r;
int p = max(l, r / 2 + 1);
cout << r % p << endl;
} signed main()
{
int T = 1; scanf("%d",&T);
while(T -- ) solve();
return 0;
}

B - Scenes From a Memory header

题意

给一个长度 \(\le 50\) 的数字, 问最多可以删除多少为使得它变成一个非质数 数据保证一定有解

分析

首先我们可以知道 长度最短的非质数1,4,6,8,9 因此我们首先特判这五个数字

其次呢, 剩下没有被使用过的数字就只有2,3,5,7 首先我们的出两个数字的所有组合(三位数以及更高位一定包含两位数,我们需要最短的

22,23,25,27,32,33,35,37,52,53,55,57,72,73,75,77 里面的质数只有23,37,53,73

因为保证一定有解, 因此我们可以排除两位数字中23,37,53,73 出现的可能, 而三位及以上的数字一定包含其他的数字

就在两位数字中的非质数 中包含了

因此所有存在的结果就只有1,4,6,8,9,22,25,27,32,33,35,52,55,57,72,75,77

一位数判断是否出现过 两位数for循环扫一遍即可

AC_CODE

#include <bits/stdc++.h>
using namespace std; int vis[1000];
int cnt[10]; inline void solve() {
for(int i = 1; i < 10; i ++ ) cnt[i] = 0;
int n;
string a;
cin >> n >> a;
for(auto c : a) cnt[c - '0'] ++;
for(int i = 1; i < 10; i ++ ) {
if(cnt[i] && vis[i]) {
cout << 1 << endl;
cout << i << endl;
return;
}
} for(int i = 0; i < n; i ++ )
for(int j = i + 1; j < n; j ++ ) {
int p = a[i] - '0', q = a[j] - '0';
int res = p * 10 + q;
if(vis[res]) {
cout << 2 << endl;
cout << res << endl;
return;
} } } signed main()
{
vis[1] = true;
vis[4] = true;
vis[6] = true;
vis[8] = true;
vis[9] = true;
vis[22] = true;
vis[25] = true;
vis[27] = true;
vis[32] = true;
vis[33] = true;
vis[35] = true;
vis[52] = true;
vis[55] = true;
vis[57] = true;
vis[72] = true;
vis[75] = true;
vis[77] = true; int T = 1; scanf("%d",&T);
while(T -- ) {
solve();
} return 0;
}

C - Rings

题意

给定一个01 串,长度为len 从中找出两个长度 \(\ge len / 2\) 的 子串

使得二者转为十进制以后具有整数倍关系

思路

思维题(想到就很简单

我们可以把原来的字符串分为两种 有0的和没有0

  • 0 存在的时候, 我们判断0是在前半段还是在后半段(假设第idx 位是0

    • 在前半段的时候, 我们可以分割成两个成1倍关系的二进制串 0xxxxxxxxxxxx
    • 在前半段的时候, 我们可以分割成两个成2倍关系的二进制串 xxxxxx0xxxxxx
  • 0 不存在时候, 我们可以分割成两个成1倍关系的二进制串 111111111111 (全是1

    代码实现起来就很简单了

AC_CODE

#include <bits/stdc++.h>
#define rep(i, b, s) for(register int i = (b); i <= (s); ++i)
using namespace std; inline void solve() {
int n; string x;
cin >> n >> x;
int px = n / 2;
rep(i, 0, n - 1) {
if(x[i] == '0') {
if(i >= px) {
printf("1 %d 1 %d \n", i + 1, i);
return;
}
else {
printf("%d %d %d %d\n", i + 1, n, i + 2, n);
return;
}
}
}
printf("%d %d %d %d\n", 1, px, 2, px + 1);
} signed main()
{
int T = 1; scanf("%d",&T);
while(T -- ) {
solve();
} return 0;
}

D1 - Two Hundred Twenty One

题意

给定一个由+- 构成的字符串 +代表 1 - 代表 -1 (即代表\(a_i\)的值

规定一个子区间的值为 \(\sum_{i = l}^{r}(-1)^{i-1}a_i\)

规定一个操作为: 删去字符串中某个字符,其他的字符顺次往前移动

给定一个子区间\([l,r]\) 求出最少要进行几次操作,才能使这个区间的值为0

分析

  • 如果已经是0的话我们就不用删除任何数字
  • 当目前子区间的值为奇数的时候

    我们一定可以找到某个下标 使得改下标左右两边的值是相等的 (因为每个位置所造成的影响的绝对值是1

    此时删去这个值会使得后面的所有值全部取反 就会导致区间的值为0
  • 偶数的时候

    我们删去头或者尾 即可把这个区间的值变为奇数 同上

AC_CODE

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define fix(a) fixed << setprecision(a)
#define debug(x) cout<<#x" ----> "<<x<<endl
#define rep(i, b, s) for(register int i = (b); i <= (s); ++i)
#define pre(i, b, s) for(register int i = (b); i >= (s); --i) //#define int long long
#define endl '\n'
#define ios ios::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define all(v) (v).begin(),(v).end() using namespace std; typedef unsigned long long ULL;
typedef pair<int, int> PII ;
typedef pair<int, PII> PIII ;// {value, {value, value}}
typedef pair<double, double> PDD ;
typedef long long LL;
const int INF = INT_MAX;
const LL INFF = INT64_MAX;
const int mod = 1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1.0); inline int lowbit(int x){return x&-x;}
inline int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}
inline LL ksm(LL a, LL b) {if (b == 0) return 1; LL ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns;}
inline LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
inline void out(bool flag);
template < typename T >
inline void read(T &x)
{
x = 0; bool f = 0; char ch = getchar();
while(!isdigit(ch)){f ^= !(ch ^ 45);ch=getchar();}
while(isdigit(ch)) x= (x<<1)+(x<<3)+(ch&15),ch=getchar();
x = f ? -x : x;
} inline void solve() {
int n, m;
cin >> n >> m;
vector<int> a(n + 1), s(n + 1);
for(int i = 1; i <= n; i ++ ) {
char cc; cin >> cc;
if(cc == '+') a[i] = 1;
else a[i] = -1;
}
rep(i, 1, n) {
if(i % 2 == 1) s[i] = s[i - 1] + a[i];
else s[i] = s[i - 1] - a[i];
}
rep(i, 1, m) {
int l, r; cin >> l >> r;
int t = abs(s[r] - s[l - 1]);
if(!t) cout << 0;
else if(t & 1) cout << 1;
else cout << 2;
cout << endl;
}
} signed main()
{
ios;
int T = 1; cin >> T;
while(T -- ) {
solve();
} return 0;
} inline void out(bool flag) {
if(flag) puts("YES");
else puts("NO");
}

Codeforces Round #741 (Div. 2)的更多相关文章

  1. Codeforces Round #741 (Div. 2), problem: (D1) Two Hundred Twenty One (easy version), 1700

    Problem - D1 - Codeforces 题意: 给n个符号(+或-), +代表+1, -代表-1, 求最少删去几个点, 使得     题解(仅此个人理解): 1. 这题打眼一看, 肯定和奇 ...

  2. Codeforces Round #741 (Div. 2)部分题题解

    我果然还是太菜了,就写了两道题....真是水死了.... A The Miracle and the Sleeper 简化题意:给定\(l,r\),求\(a\)%\(b\)的最大值,其中\(r> ...

  3. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  4. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  5. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  6. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  7. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  8. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  9. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

随机推荐

  1. 1057 - Collecting Gold

    1057 - Collecting Gold   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB ...

  2. Lucky7(hdu5768)

    Lucky7 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  3. Intervals(poj1201)

    Intervals Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24134   Accepted: 9177 Descri ...

  4. 『学了就忘』vim编辑器基础 — 94、vim编辑器介绍

    目录 1.vim编辑器简介 2.vim的工作模式 (1)命令模式 (2)输入模式 (3)最后行模式(末行模式) 1.vim编辑器简介 vim是一个全屏幕纯文本(绘个表格或者插个图片就不要想了)编辑器, ...

  5. 【模型推理】量化实现分享三:详解 ACIQ 对称量化算法实现

      欢迎关注我的公众号 [极智视界],回复001获取Google编程规范   O_o   >_<   o_O   O_o   ~_~   o_O   大家好,我是极智视界,本文剖析一下AC ...

  6. [数学]高数部分-Part VII 微分方程

    Part VII 微分方程 回到总目录 Part VII 微分方程 微分方程的概念 一阶微分方程求解-变量可分离型 一阶微分方程求解-齐次型 一阶微分方程求解-一阶线性型 二阶常系数齐次D.E.求解: ...

  7. 在linux(deepin)系统下查看当前ip地址与用户名

    在linux(deepin)系统下查看当前ip地址与用户名 查看当前ip地址 方式一: hostname -I 方式二: ifconfig -a 如下图所示: 其中192.168.11.66即为当前系 ...

  8. 揭开“QUIC”的神秘面纱

    作者:赵咏 QUIC的发音类似于Quick,实际上也确实很快.它可以很好地解决应用在传输层和应用层面临的各种需求,包括处理更多的连接.安全性以及低延迟. 目前在互联网领域,QUIC可以说刮起了新一代互 ...

  9. 对接网易云信音视频2.0呼叫组件集成到vue中,实现web端呼叫app,视频语音通话。

    项目中需要实现视频通话功能,经过公司的赛选,采用网易云信的视频通话服务,app小伙伴集成很顺利.web端需要实现呼叫app端用户.网易云信文档介绍不全,vue的demo满足不了需求,和客服人员沟通,只 ...

  10. SpringBoot集成log4j,解决log4j.properties不生效问题

    Spring Boot集成log4j其实比较简单,maven的话,在xml中增加log4j依赖就行 <dependency> <groupId>org.springframew ...