Codeforces Round #518 (Div. 2) [Thanks, Mail.Ru!]

https://codeforces.com/contest/1068

A

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 300005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long mod=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
ll n,m,k,l;
cin>>n>>m>>k>>l;
if(n<m||n-k<l){
cout<<-<<endl;
return ;
}
ll res=(k+l)/m;
if(res*m<k+l) ++res;
if(res*m<=n) cout<<res<<endl;
else cout<<-<<endl;
}

B

数论

因为lcm(a,b)/a==b/gcd(a,b),又因为b是确定的,所以求的是gcd(a,b)的个数,也就是求b的因子数

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 300005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long mod=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
ll n;
cin>>n;
int sq=sqrt(n);
ll ans=;
for(int i=;i<=sq;i++){
ll co=;
while(n%i==){
n/=i;
co++;
}
ans*=co;
}
if(n>) ans*=;
cout<<ans<<endl;
}

C

找规律

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 300005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long mod=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ vector<int>ve[];
int n,m; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=;i<=n;i++){
ve[i].pb(i);
}
int x,y;
int co=n+;
for(int i=;i<m;i++){
cin>>x>>y;
ve[x].pb(co);
ve[y].pb(co);
co++;
}
for(int i=;i<=n;i++){
cout<<ve[i].size()<<endl;
for(int j=;j<ve[i].size();j++){
cout<<i<<" "<<ve[i][j]<<endl;
}
}
}

D

DP

参考博客:https://blog.csdn.net/white_156/article/details/83421537

 #include<iostream>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long mod=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int a[];
long long dp[][][]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
scanf("%d",&n);
for(int i=;i<=n;i++) cin>>a[i];
if(a[]!=-){
dp[][a[]][]=;
}
else{
for(int i=;i<=;i++){
dp[][i][]=;
dp[][i][]=;
}
}
for(int i=;i<=n;i++){
if(a[i]==-){
dp[i][][]=;
for(int j=;j<=;j++)
dp[i][j][]=(dp[i][j][]+dp[i][j-][]+dp[i-][j-][]+dp[i-][j-][])%mod;
dp[i][][]=;
for(int j=;j>=;j--){
dp[i][j][]=(dp[i][j][]+dp[i][j+][]+dp[i-][j+][])%mod;
}
for(int j=;j<=;j++)
dp[i][j][]=(dp[i][j][]+dp[i-][j][]+dp[i-][j][])%mod;
}
else{
int num=a[i];
for(int j=;j<num;j++)
dp[i][num][]=(dp[i][num][]+dp[i-][j][]+dp[i-][j][])%mod;
for(int j=num+;j<=;j++)
dp[i][num][]=(dp[i][num][]+dp[i-][j][])%mod;
dp[i][num][]=(dp[i][num][]+dp[i-][num][]+dp[i-][num][])%mod;
}
}
long long ans=;
for(int i=;i<=;i++)
ans=(ans+dp[n][i][])%mod;
cout<<ans<<endl; }

E

模拟

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long mod=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ set<int>se[maxn],v,t;
set<int>::iterator it;
int cnt[maxn]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n,k;
cin>>n>>k;
for(int i=;i<n;i++)
{
int u,v;
cin>>u>>v;
se[u].insert(v);
se[v].insert(u);
}
for(int i=;i<=n;i++)
if(se[i].size()==)
v.insert(i);
while(n>)
{
t.clear();
for(it=v.begin();it!=v.end();it++)
{
int x=*se[*it].begin();
cnt[x]++;
t.insert(x);
se[x].erase(*it);
n--;
}
for(it=t.begin();it!=t.end();it++)
{
if(cnt[*it]<)
{
printf("No\n");
return ;
}
cnt[*it]=;
}
swap(v,t);
k--;
}
if(k==)printf("Yes\n");
else printf("No\n"); }

Codeforces Round #518 (Div. 2) [Thanks, Mail.Ru!]的更多相关文章

  1. 【2000*】【Codeforces Round #518 (Div. 1) [Thanks, Mail.Ru!] B】Multihedgehog

    [链接] 我是链接,点我呀:) [题意] [题解] 找到度数为1的点. 他们显然是叶子节点. 然后每个叶子节点. 往上进行bfs. 累计他们的父亲节点的儿子的个数. 如果都满足要求那么就继续往上走. ...

  2. Codeforces Round #518 (Div. 2) B. LCM gcd+唯一分解定律

    题意:给出b 求lcm(a,b)/a 在b从1-1e18有多少个不同得结果 思路lcm*gcd=a*b  转换成    b/gcd(a,b) 也就是看gcd(a,b)有多少个值  可以把b 由唯一分解 ...

  3. Codeforces Round #518 (Div. 2) B LCM

    传送门 https://www.cnblogs.com/violet-acmer/p/10163375.html 题解: 这道题有点意思,有点数学的味道. 根据定义“[a,b] / a”可得这求得是l ...

  4. Codeforces Round #518 Div. 1没翻车记

    A:设f[i][j][0/1]为前i个数第i位为j且第i位未满足/已满足限制的方案数.大力dp前缀和优化即可. #include<iostream> #include<cstdio& ...

  5. Codeforces Round #518 (Div. 2) D(计数DP)

    #include<bits/stdc++.h>using namespace std;const long long mod=998244353;int n;int a[100007];l ...

  6. 【Codeforces Round #518 (Div. 2)】

    A:https://www.cnblogs.com/myx12345/p/9847588.html B:https://www.cnblogs.com/myx12345/p/9847590.html ...

  7. Codeforces Round #518 (Div. 1) Computer Game 倍增+矩阵快速幂

    接近于死亡的选手没有水平更博客,所以现在每五个月更一篇. 这道题呢,首先如果已经有权限升级了,那么后面肯定全部选的是 \(p_ib_i\) 最高的. 设这个值为 \(M=\max \limits_i ...

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

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

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

随机推荐

  1. IUSER 匿名帐户密码获取

    如何获取IUSR帐号和密码呢?有两种方法 1.安装IIS Resources,打开IIS Resources中的Metabase Explorer->机器名->LM->W3SVC-& ...

  2. mongodb学习-练习实例

    C:\Users\issuser>mongoMongoDB shell version: 2.4.6connecting to: test> db.user.find(){ "_ ...

  3. Others-阿里专家强琦:流式计算的系统设计和实现

    阿里专家强琦:流式计算的系统设计和实现 更多深度文章,请关注云计算频道:https://yq.aliyun.com/cloud 阿里云数据事业部强琦为大家带来题为“流式计算的系统设计与实现”的演讲,本 ...

  4. 虚拟机扩容mac

    VMware虚拟机Mac增大容量: 1.设置硬盘容量大小 2.打开虚拟机的终端,找到需要扩展的硬盘.输入命令 :diskutil list 注意 :我的硬盘名字叫yz,这一行可以看见当前分配容量,最后 ...

  5. vue:在路由跳转中使用拦截器

    1:首先在路由对象中的某一个具体的路由对象加这样一个属性 meta: {  requireAuth:true  } 2:然后在main.js中添加这段代码 router.beforeEach((to, ...

  6. 2018SDIBT_国庆个人第四场

    A - A  这题很巧妙啊,前两天刚好做过,而且就在博客里  Little C Loves 3 I time limit per test 1 second memory limit per test ...

  7. happyxiaofan的程序员书单

    转自   happyxiaofan 读书的看法 从15年7月至今,研究生期间读了不少书,读书让我学到了很多,也是提升技术能力的一个重要手段.可能很多人嫌读书太花时间,曾经的我一度也是这么认为的,觉得一 ...

  8. 四则运算3+PSP

    题目要求: 1.要求在第二次实验(四则运算2)的基础上加上其他功能. 2.要求能够在每个运算式打印出来后,用户能够进行输入计算的答案,并且程序进行判断给出用户输入的答案的正确性. 3.要求实现四则混合 ...

  9. ubuntu上装MySQL遇到的问题及解决办法

    验证原有主机上是否已安装mysql                运行sudo netstat -tap | grep mysql命令查看是否有Mysql的端口 查看到mysql已安装上了: 启动my ...

  10. vue练习

    <div id="app"> <div> <span>姓名</span> <input type="text&quo ...