【CodeForces】Educational Codeforces Round 118 (Rated for Div. 2)【A-C】
A. Long Comparison
思路
- 先判断字符长度
- 相等的字符长度判断填满0后判断字典序
AC代码
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")#include<bits/stdc++.h>
using namespace std;typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 2e5+10;ll a[maxn];
ll b[maxn];int main(void){#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);
#endif int t;cin >> t;while(t--){string x1;int p1;string x2;int p2;cin >> x1 >> p1;cin >> x2 >> p2;int len1 = x1.size();int len2 = x2.size();if(len1+p1 > len2+p2) cout<<">"<<endl;else if(len1+p1 < len2+p2) cout<<"<"<<endl;else{if(len1==len2){if(x1 > x2) cout<<">"<<endl;else if(x1 < x2) cout<<"<"<<endl;else cout<<"="<<endl;}else{if(len1 < len2){for(int i = 1; i <= len2-len1; ++i) x1 += '0';if(x1>x2) cout<<">"<<endl;else if(x1<x2) cout<<"<"<<endl;else cout<<"="<<endl;}else{for(int i = 1; i <= len1-len2; ++i) x2 += '0';if(x1>x2) cout<<">"<<endl;else if(x1<x2) cout<<"<"<<endl;else cout<<"="<<endl;}}}}return 0;
}
B. Absent Remainder
思路
a%b<ba\%b < ba%b<b,找到最小的b即可。
AC代码
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")#include<bits/stdc++.h>
using namespace std;typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 2e5+10;ll a[maxn];
ll b[maxn];int main(void){#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);
#endif int t;cin >> t;while(t--){int n;cin >> n;for(int i = 1; i <= n; ++i) cin >> a[i];sort(a+1,a+1+n);for(int i = 1; i <= n/2; ++i){cout<<a[i+1]<<" "<<a[1]<<endl;}}return 0;
}
C. Poisoned Dagger
思路
二分K即可。
AC代码
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")#include<bits/stdc++.h>
using namespace std;typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 2e5+10;ll a[maxn];
ll b[maxn];
ll n,h;
ll check(ll mid){ll sum = 0;for(int i = 1; i <= n-1; ++i) sum += min(mid,a[i+1]-a[i]);sum += mid;return sum;
}
int main(void){#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);
#endif int t;cin >> t;while(t--){cin >> n >> h;for(int i = 1; i <= n; ++i) cin >> a[i];ll l = 1;ll r = h;while(l < r){ll mid = (l+r) >> 1;if(check(mid) < h) l = mid+1;else r = mid;}cout<<l<<endl;}return 0;
}
【CodeForces】Educational Codeforces Round 118 (Rated for Div. 2)【A-C】相关推荐
- 【Educational CF Round 86 (Rated for Div. 2) / 1342 A + B】- A. Road To Zero + B. Binary Perio - 水题
目录 A. Road To Zero 题目大意 思路 代码 B. Binary Period 题目大意 思路 代码 A. Road To Zero time limit per test :1 sec ...
- Educational Codeforces Round 118 (Rated for Div. 2)/C. Poisoned Dagger
记录自己两个月前打CF以来第一个在时限内过掉的C题(好耶!) 简单二分 #include<bits/stdc++.h> using namespace std; #define ll lo ...
- Educational Codeforces Round 118 (Rated for Div. 2) C. Poisoned Dagger(二分或搜索)
C. Poisoned Dagger 题意: Monocarp is playing yet another computer game. In this game, his character ha ...
- Educational Codeforces Round 118 (Rated for Div. 2) A-C
D的难度跨度太大了,先不写了. A. Long Comparison 给出一个数字x1,后面添加p1个0,一个数字x2,后面添加p2个0.比较两个数字的大小,输出比较的情况. x和p都是10的6次方的 ...
- Educational Codeforces Round 103 (Rated for Div. 2)前四题
Educational Codeforces Round 103 (Rated for Div. 2) 第二次被别人hack,悲 A - K-divisible Sum 题意 给定两个整数 n,kn, ...
- 【CF比赛】Educational Codeforces Round 102 (Rated for Div. 2)
题目来源 Educational Codeforces Round 102 (Rated for Div. 2) A. Replacing Elements 只要判断最大值是否小于等于d,或者第一个值 ...
- Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...
- Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...
- Educational Codeforces Round 37 (Rated for Div. 2) 1
Educational Codeforces Round 37 (Rated for Div. 2) A.Water The Garden 题意:Max想给花园浇水.花园可被视为长度为n的花园床,花园 ...
最新文章
- TensorFlow支持Unicode,中文NLP终于省心了
- 如何使用Android studio创建签名
- 利用GetPrivateProfileString读取配置文件(.ini)
- network packet
- 用户登录色一句java_用户权限及角色
- 计算高斯混合模型的可分性和重叠度(Overlap Rate, OLR)
- python yield
- GTX1060 6G是低端电脑显卡吗?
- 关于jstl EL用法的注意点(java.lang.NumberFormatException: For input string: userName)
- 高等代数——大学高等代数课程创新教材(丘维声)——2.4笔记+习题
- 《商务与经济统计》学习笔记(七)—各统计分布知识点归纳
- PHP反序列化字符串溢出
- ftp工具哪个好,推荐8个超级好用而且免费的ftp工具,支持中文版windows系统的。
- 车轱辘通知挪车、车牌识别
- 灵境元宇宙 ---论元宇宙之本真
- UE4_直播RT输出到OBS教程
- WinX DVD Ripper for Mac(DVD视频格式转换工具)
- 人工智能技术发展概述
- J1angの小白式kafka学习总结(1)
- Xd等设计可用的相关资源整理