A Integer Moves

题意:略
题解:一共就三种情况,具体略(
需要注意的是sqrt()返回的并不是整型,记得前面加(Int)

#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
#define sc scanf
#define pr printf
#define ll long long
#define mod 998244353
#define INT INT_MAX
ll dp[maxn][5];
int main() {int t;cin>>t;while(t--){int x,y;cin>>x>>y;int k=(int)sqrt(x*x+y*y)*(int)sqrt(x*x+y*y);//cout<<k<<"aaaa"<<(x*x+y*y)<<endl;if(x==y&&x==0)cout<<0<<endl;else if(k==(x*x+y*y))cout<<1<<endl;else cout<<2<<endl;}return 0;
}

B XY Sequence

题意:略
题解:个人人为这个比A更清晰,模拟一下过程即可。能加则加,否则减。这样可尽最大可能加最多。

#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
#define sc scanf
#define pr printf
#define ll long long
#define mod 998244353
#define INT INT_MAX
ll dp[maxn][5];
int main() {int t;cin>>t;while(t--){ll n,b,x,y;sc("%lld%lld%lld%lld",&n,&b,&x,&y);ll sum=0;ll now=0;for(int i=0;i<n;i++){if(now+x<=b)now+=1ll*x;else now-=1ll*y;sum+=now;}pr("%lld\n",sum);}return 0;
}

C Bracket Sequence Deletion

题意:两种方法消前缀,且题目说了the shortest prefix,即最短前缀。
而消前缀两种方法:
1.匹配 2.回文

题解:
这题乍一看立马想到括号匹配,仔细一想被带歪了
因为一共就几种情况:(我觉得括号很能迷惑人,改成字符就很恨很清楚)
1.( )可以消去——匹配
2.( ( 可以消去——aa
3. ) )可以消去——bb
4. )( 待定
)( 看作ba,可知无论中间的a有多少,找到一个b即可回文,即baaaaaab,如果没有,则不可能再消去了。

#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
#define sc scanf
#define pr printf
#define ll long long
#define mod 998244353
#define INT INT_MAX
int main() {int t;cin>>t;while(t--){int n;sc("%d",&n);string s;cin>>s;int ans=0;int i;for(i=0;i<s.size()-1;){if(s[i]==')'&&s[i+1]=='('){int c=i;i+=2;while(i<s.size()){if(s[i]!=')') i++;else break;}if(i<s.size()&&s[i]==')'){ans++,i++;}else {i=c;goto ans;}}else {ans++;i+=2;}}ans:pr("%d %d\n",ans,s.size()-i);}return 0;
}

D For Gamers. By Gamers.

题意:
士兵n,拥有金币C;
对n个士兵,每一个拥有花费:ci,伤害:di,生命hi。
怪物m;
对m个怪物,每一个拥有伤害:di,生命hi。
求,对m种怪物的最少金币杀死方案。
需注意:
1.Monocarp chooses one type of units
它每次只能选择一组士兵,可无限次重复消费ci
2.not once per second
不是论秒判断胜负,这里需要结合示例分析

题解:
可以看出:需满足
x为选择x次
(不用数学工具编了,直接看吧


存下dixhi-1的数组,然后二分查找满足题意的。

具体实现注意
一个数组di,hi
一个数组储存满足题意的dixhi-1
二分用到的数组,需要对第二个数组作处理:从前到后求前缀最大值

注意定义为ll会减少很多麻烦,不然多处都要特殊处理,容易遗忘。

#include<bits/stdc++.h>
#define ll long long
#define sc scanf
#define pr printf
using namespace std;
const ll maxn=1e6+10;
ll ci[maxn];
ll k[maxn];
int main()
{int n,C;cin>>n>>C;ll c,d,h;for(int i=0;i<n;i++){sc("%lld%lld%lld",&c,&d,&h);ci[c]=max(ci[c],h*d);}for(int i=1;i<=C;i++)//+1????for(int j=i;j<=C;j+=i)k[j]=max(k[j],(j/i)*ci[i]-1);for(int i=1;i<=C;i++)k[i]=max(k[i],k[i-1]);int m;cin>>m;while(m--){sc("%lld%lld",&c,&h);ll x=c*h;int ans=lower_bound(k,k+C+1,x)-k;if(ans>C)pr("-1\n");else pr("%d ",ans);}pr("\n");return 0;
}

【写在后面的碎碎念】
这题刚看到的时候,觉得有点像背包?但是因为注意1又否定。
n,m的范围是3e5,怎么莽怎么错,也想不到优化。
然后想,那会是每一组的值确定,例如dh相乘什么的?然后再二分?
但是应该是交叉的关系,怎么可能是这样。
遂放弃。
于是发现是自己数学不好()

【Educational Cf Round 125 】A—D相关推荐

  1. 【Educational Codeforces Round 138】A. Cowardly Rooks

    Educational Codeforces Round 138中A. Cowardly Rooks Codeforces比赛记录 文章目录 题目链接: 一.A. Cowardly Rooks 题目意 ...

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

  3. 【Educational Codeforces Round 6A】【水题】Professor GukiZ's Robot 曼哈顿距离

    A. Professor GukiZ's Robot time limit per test 0.5 seconds memory limit per test 256 megabytes input ...

  4. 【Educational Codeforces Round 10C】【脑洞 SET】Foe Pairs 不含有敌对pair的区间数

    C. Foe Pairs time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  5. 【codeforces】【比赛题解】#915 Educational CF Round 36

    虽然最近打了很多场CF,也涨了很多分,但是好久没写CF的题解了. 前几次刚刚紫名的CF,太伤感情了,一下子就掉下来了,不懂你们Div.1. 珂学的那场我只做了第一题--悲伤. 这次的Education ...

  6. 【CF补题】【D】Educational Codeforces Round 125 (Rated for Div. 2) C++代码

    D. For Gamers. By Gamers. 现有 n 种兵种,每种有单位招募代价.攻击力.生命值三个数值.需回答 m 次询问--每次询问给出魔王的攻击.生命,问在以下条件下,击败魔王至少需要花 ...

  7. 【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix

    [链接] 我是链接,点我呀:) [题意] 告诉你每一行.每一列的异或和. 让你求出一个符合要求的原矩阵. [题解] 显然应该有 a1^a2^....^an = b1^b2^....^bn 也即两边同时 ...

  8. 【Educational Codeforces Round 61 (Rated for Div. 2)】A.B.C.D.E.F.G

    前言 这场在最开始很顺利,A题6min1A,B题14min1A,但是由于C题过题人数太少一度认为这个C题很难,等有人过了才开始写最开始的想法,C题40min1A,过C之后发现F过的很多,去看提,发现和 ...

  9. 【Codeforces Global Round 23】B. Rebellion

    Codeforces Global Round 23中B. Rebellion Codeforces比赛记录 文章目录 题目链接: 一.B. Rebellion 题目意思: 上思路: 总结 B. Re ...

最新文章

  1. 2.1.3 计算机网络之编码与调制
  2. aws 静态网站_如何使用AWS托管静态网站-入门指南
  3. linux中initrd的含义,Linux2.6 内核的 Initrd 机制解析
  4. 网抑云熬夜打卡源码+微信登录+免签支付+今日打卡统计
  5. Unity3D:Graphics.BlitMultiTap方法
  6. springboot整合jwt_Spring Boot整合JWT实现用户认证(附源码)
  7. mysql已死 subsys被锁_centos6.5安装MYSQL“mysqld已死,但是subsys被锁”的解决方案
  8. 基本Linux命令的用法
  9. FTP:226 transfer done but failed to open directory
  10. Airflow任务调度延时问题分析和优化
  11. python写一个笔记软件_科学网—python学习笔记(1)——创建应用 - 高雪峰的博文...
  12. 矩阵分解在推荐系统中的应用:NMF和经典SVD实战(2)
  13. CVE-2018-8120 漏洞分析
  14. 用语音聊天系统源码做语音聊天app开发
  15. 中国农业大学821数据结构计算机考研
  16. 计算机突然蓝屏重启,最近电脑经常蓝屏重启。
  17. hdu 4622 Reincarnation(SAM)
  18. 怎样设置用键盘开机?
  19. 程序员需要建立的对技术、业务、行业、管理、投资的认知
  20. 育儿知识小分享—— 如何引导孩子学会分享

热门文章

  1. Qt5之QWS和QPA
  2. STC32G单片机驱动1.8寸TFT LCD128X160 ST7735S SPI串口驱动示例
  3. Ubuntu命令集(2011.11.23始-用到记录)
  4. python爬取男人装
  5. ROS学习第七天 机器人系统设计(一)——(仿真导航)
  6. C# menuStrip 配置
  7. vue-transitions切换路由时更加平滑
  8. 如何从上位机或者触摸屏设定Time或S5Time值?
  9. Input Queue Drops
  10. python之syslog学习 - 坏男孩 - 51CTO技术博客