A. Long Comparison

思路

  1. 先判断字符长度
  2. 相等的字符长度判断填满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】相关推荐

  1. 【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 ...

  2. Educational Codeforces Round 118 (Rated for Div. 2)/C. Poisoned Dagger

    记录自己两个月前打CF以来第一个在时限内过掉的C题(好耶!) 简单二分 #include<bits/stdc++.h> using namespace std; #define ll lo ...

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

  4. Educational Codeforces Round 118 (Rated for Div. 2) A-C

    D的难度跨度太大了,先不写了. A. Long Comparison 给出一个数字x1,后面添加p1个0,一个数字x2,后面添加p2个0.比较两个数字的大小,输出比较的情况. x和p都是10的6次方的 ...

  5. Educational Codeforces Round 103 (Rated for Div. 2)前四题

    Educational Codeforces Round 103 (Rated for Div. 2) 第二次被别人hack,悲 A - K-divisible Sum 题意 给定两个整数 n,kn, ...

  6. 【CF比赛】Educational Codeforces Round 102 (Rated for Div. 2)

    题目来源 Educational Codeforces Round 102 (Rated for Div. 2) A. Replacing Elements 只要判断最大值是否小于等于d,或者第一个值 ...

  7. Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...

  8. Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...

  9. Educational Codeforces Round 37 (Rated for Div. 2) 1

    Educational Codeforces Round 37 (Rated for Div. 2) A.Water The Garden 题意:Max想给花园浇水.花园可被视为长度为n的花园床,花园 ...

最新文章

  1. TensorFlow支持Unicode,中文NLP终于省心了
  2. 如何使用Android studio创建签名
  3. 利用GetPrivateProfileString读取配置文件(.ini)
  4. network packet
  5. 用户登录色一句java_用户权限及角色
  6. 计算高斯混合模型的可分性和重叠度(Overlap Rate, OLR)
  7. python yield
  8. GTX1060 6G是低端电脑显卡吗?
  9. 关于jstl EL用法的注意点(java.lang.NumberFormatException: For input string: userName)
  10. 高等代数——大学高等代数课程创新教材(丘维声)——2.4笔记+习题
  11. 《商务与经济统计》学习笔记(七)—各统计分布知识点归纳
  12. PHP反序列化字符串溢出
  13. ftp工具哪个好,推荐8个超级好用而且免费的ftp工具,支持中文版windows系统的。
  14. 车轱辘通知挪车、车牌识别
  15. 灵境元宇宙 ---论元宇宙之本真
  16. UE4_直播RT输出到OBS教程
  17. WinX DVD Ripper for Mac(DVD视频格式转换工具)
  18. 人工智能技术发展概述
  19. J1angの小白式kafka学习总结(1)
  20. Xd等设计可用的相关资源整理

热门文章

  1. Unity3D 游戏引擎之构建简单的游戏世界(三)
  2. 用Python + Wxpy 为女友搭建简单微信机器人
  3. 如何训练GAN?训练GAN的技巧和方法
  4. 解决电脑不能进入BIOS页面
  5. 2019年1-6月网络安全态势分析及建议
  6. 认认真真推荐几个Python、统计学、算法、机器学习...等方向的公众号
  7. CSS实现中英双语导航栏——利用块级元素隐藏实现
  8. 什么是数据规约,数据规约的策略都有哪些
  9. 安卓Okhttp3源码的简单分析
  10. 【Redis】Redis数据结构与对象(一)简单动态字符串(SDS)