Codeforces Round #518 (Div. 2) [Thanks, Mail.Ru!]
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!]的更多相关文章
- 【2000*】【Codeforces Round #518 (Div. 1) [Thanks, Mail.Ru!] B】Multihedgehog
[链接] 我是链接,点我呀:) [题意] [题解] 找到度数为1的点. 他们显然是叶子节点. 然后每个叶子节点. 往上进行bfs. 累计他们的父亲节点的儿子的个数. 如果都满足要求那么就继续往上走. ...
- 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 由唯一分解 ...
- Codeforces Round #518 (Div. 2) B LCM
传送门 https://www.cnblogs.com/violet-acmer/p/10163375.html 题解: 这道题有点意思,有点数学的味道. 根据定义“[a,b] / a”可得这求得是l ...
- Codeforces Round #518 Div. 1没翻车记
A:设f[i][j][0/1]为前i个数第i位为j且第i位未满足/已满足限制的方案数.大力dp前缀和优化即可. #include<iostream> #include<cstdio& ...
- 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 ...
- 【Codeforces Round #518 (Div. 2)】
A:https://www.cnblogs.com/myx12345/p/9847588.html B:https://www.cnblogs.com/myx12345/p/9847590.html ...
- Codeforces Round #518 (Div. 1) Computer Game 倍增+矩阵快速幂
接近于死亡的选手没有水平更博客,所以现在每五个月更一篇. 这道题呢,首先如果已经有权限升级了,那么后面肯定全部选的是 \(p_ib_i\) 最高的. 设这个值为 \(M=\max \limits_i ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- PHP数据库基于PDO操作类(mysql)
这是网上找的关于Mysql的操作类,非常适合初学者使用 <?php class Mysql { protected static $_dbh = null; //静态属性,所有数据库实例共用,避 ...
- 2319__1.5.3 Superprime Rib 特殊的质数肋骨
[Submit][Status][Forum] Description 农民约翰母牛总是产生最好的肋骨. 你能通过农民约翰和美国农业部标记在每根肋骨上的数字认出它们. 农民约翰确定他卖给买方的是真正的 ...
- AS_简单的开始
1.注释 单行注释 // 多行注释 /* src */ 2.变量 变量名,可以包含字母.数字.下划线.$.但不以数字开头. 变量类型,是严格数据类型.AS有静态类型 ...
- Mac下如何安装WebStorm + 破解
1.官网下载 下载地址 选择好系统版本以后,点击DOWNLOAD 2.安装 双击下载好的安装包.将WebStromt拖入application文件夹,然后在Launchp ...
- 【剑指offer】单链表尾部插入一个节点
#include <iostream> using namespace std; //链表结构体 struct ListNode { int m_Value; ListNode *next ...
- 解决eclipse+adt出现的 loading data for android 问题
因为公司最近做的项目中有用到一些第三方demo,蛋疼的是这些demo还比较旧...eclipse的... 于是给自己的eclipse装上了ADT插件,但是...因为我的eclipse比较新,Versi ...
- (转)关闭win10的Skype
https://blog.csdn.net/qq_38285661/article/details/86663849 使用win10的小伙伴们,有没有发现一个不用的功能Skype,假如你想卸载又怕卸不 ...
- fwrite()中参数含义——size和count经常用搞反
函数原型:size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream); 注意:这个函数以二进制形式对文件进 ...
- Unity3D之Lightmap详解
作者:李志健 Unity 完全集成了光照贴图,可以通过编辑器创建完整的光照贴图,你完全不用担心,所有材质会自动获得光照贴图.光照贴图的意思是,所有灯光的特性将被直接映射到Beast lightmapp ...
- 吴裕雄 python 爬虫(3)
import hashlib md5 = hashlib.md5() md5.update(b'Test String') print(md5.hexdigest()) import hashlib ...