A. Mezo Playing Zoma

题意:给你一个向右向左的指令,每个指令可以朝那个方向走一个单位,问你可以随意选出子序列来走,那可能到达的点有多少个。

思路:从范围上考虑就秒了。看最左和最右能到哪,然后加上原点就是所有可能的点数

view code
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0', ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} }; int main()
{
ll n = read();
string s;
cin>>s;
int l = 0, r = 0;
for(int i=0; i<s.size(); i++)
{
if(s[i] == 'L') l++;
else r++;
}
cout<<l+r+1<<endl;
return 0;
}

B. Just Eat It!

题意:给你一个序列,问你所有的和是否严格大于所有子段(不包含[1,n]这个)的和。

思路:其实就是模板题。求一个最大字段和,同时记录开始和结束位置。若存在一个满足限制条件的最大字段和dp[i],则输出NO,反之输出YES。

view code
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0', ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} }; ll dp[maxn];
ll a[maxn];
ll s[maxn];
ll t[maxn]; int main()
{
int kase;
cin>>kase;
while(kase--)
{
ll n = read();
rep(i,0,n+1) dp[i] = 0;
ll sum = 0;
rep(i,1,n) a[i] = read(), sum += a[i];
ll st = 1, ed = 1;
rep(i,1,n)
{
if(dp[i-1] + a[i] > a[i])
{
dp[i] = dp[i-1] + a[i];
ed = i;
s[i] = st, t[i] = ed;
}
else
{
dp[i] = a[i];
s[i] = t[i] = st = ed = i;
}
}
int flag = 0;
rep(i,1,n) if(dp[i]>=sum&&!(s[i]==1&&t[i]==n)) {flag=1; break;}
puts(flag?"NO":"YES");
}
return 0;
}

C. Fadi and LCM

题意:问你找到一对(a,b),在满足 LCM(a,b) = X 的情况下找出max(a,b)最小的一对。

由于\(LCM(a,b)\) = \(ab\over gcd(a,b)\),所以当\(gcd(a,b)\)=1的时候能把ab限制的最小。所以只需要枚举一遍[1,\(\sqrt{x}\)]找到max(a,b)最小的对即可。

view code
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0', ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} }; int main()
{
ll x = read();
ll m = sqrt(x*1.0);
ll ansx = x, ansy = 1;
rep(i,1,m)
{
if(x%i) continue;
ll j = x/i;
if(gcd(i,j)==1&&max(i,j)<max(ansx,ansy)) ansx = i, ansy = j;
}
cout<<ansx<<' '<<ansy<<'\n';
return 0;
}

Codeforces Round #613 (Div. 2) ABC 题解的更多相关文章

  1. Codeforces Round #312 (Div. 2) ABC题解

    [比赛链接]click here~~ A. Lala Land and Apple Trees: [题意]: AMR住在拉拉土地. 拉拉土地是一个很漂亮的国家,位于坐标线.拉拉土地是与著名的苹果树越来 ...

  2. # Codeforces Round #529(Div.3)个人题解

    Codeforces Round #529(Div.3)个人题解 前言: 闲来无事补了前天的cf,想着最近刷题有点点怠惰,就直接一场cf一场cf的刷算了,以后的题解也都会以每场的形式写出来 A. Re ...

  3. Codeforces Round #557 (Div. 1) 简要题解

    Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...

  4. Codeforces Round #540 (Div. 3) 部分题解

    Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选 ...

  5. Codeforces Round #538 (Div. 2) (A-E题解)

    Codeforces Round #538 (Div. 2) 题目链接:https://codeforces.com/contest/1114 A. Got Any Grapes? 题意: 有三个人, ...

  6. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  7. Codeforces Round #527 (Div. 3) ABCDEF题解

    Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入 ...

  8. Codeforces Round #499 (Div. 1)部分题解(B,C,D)

    Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...

  9. 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 ...

  10. Codeforces Round #545 (Div. 1) 简要题解

    这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...

随机推荐

  1. CentOS linux安装nginx

    1.下载nginx-1.21.3.tar.gz 及 nginx-upstream-fair-master.zip 2.上传nginx-upstream-fair-master至/app/server/ ...

  2. PHP连MYSQL查询结果中文乱码的完美解决方法

    问题背景:近日接手同事的一个项目(wampserver环境),配置好环境,导库完毕,打开页面一看中文全是问号.打开network看了下请求,请求结果里的中文也一样乱码了.懵逼... 解决方法:打开My ...

  3. 解决 podman 容器无法在宿主机和容器内部相互访问问题的记录

    解决 podman 容器无法在宿主机和容器内部相互访问问题的记录 近期在使用 podman 时,遇到了容器无法在宿主机和容器内部相互访问的问题.经过一番探索,参考了这篇文章,成功解决了该问题.在此,我 ...

  4. Maven依赖冲突解决方案:调解规则与工具实践

    结论先行 Maven解决依赖冲突的核心机制是 依赖调解 和 显式排除 ,并通过插件(如maven-dependency-plugin.maven-enforcer-plugin和Maven Helpe ...

  5. Sublime Text4 4192 安装和一键激活

    介绍 此教程用于Windows 下Sublime Text4 4192版本的安装和激活. 无需安装其他软件,无需下载替换文件,无需注册机等. 官网: https://www.sublimetext.c ...

  6. Windows管理小工具

    Windows 管理小工具 概述 Windows 管理小工具 是一个基于批处理脚本的多功能工具,旨在帮助用户快速管理 Windows 系统中的常见设置和功能.通过简单的菜单操作,用户可以轻松完成 Wi ...

  7. FHQ treap(无旋treap)

    平衡树 平衡树作为一种中级数据结构,有着广泛的使用场景.其平衡性的维护方式灵活多变,而其中的无旋treap更以简单著称 P3369 [模板]普通平衡树 题意: 需维护以下操作: 插入一个数 x. 删除 ...

  8. 网络编程:TCP 网络编程

    参考:盛延敏:网络编程实战 TCP TCP,又被叫做字节流套接字(Stream Socket),UDP 也有一个类似的叫法, 数据报套接字(Datagram Socket),一般分别以"SO ...

  9. 赣CTF-Misc方向wp

    checkin 下载附件,一张图片,拖进010,在文件尾看到隐藏文本,提取并用社会主义价值解密 ez_forensics 提示为结合题目进行想象,我们会想到取证第一步vc挂载,但是需要密码,研究图片, ...

  10. RWKV-7 架构理解

    阅读之前你可以前往 RWKV wiki 了解一些关于 RWKV 的基本知识,不过他们的 wiki 似乎没有对模型架构的详细介绍,于是便有了这篇文章. RWKV-7 的核心:动态状态演化机制 RWKV- ...