Codeforces 488C Fight the Monster】的更多相关文章

Fight the Monster time limit per test             1 second                                   memory limit per test       256 megabytes                                   input                               standard input                               …
题意:打怪兽.可增加自己的属性,怎样在能打倒怪兽的情况下花费最少? 这题关键要找好二分的量.一开始我觉得,只要攻击到101,防御到100,就能必胜,于是我对自己的三个属性的和二分(0到201),内部三层循环(最多到不了200*200*200).1秒内能过.不过发现如果生命值很便宜,防御很贵的话,买生命值合算.10100点生命值就能必赢,于是上界调为10100,超时. 后来就想,二分攻击(记为i)和防御(记为j)的和mid,内部二重循环列出i+j=mid的所有情况.再单独二分生命值k,如果ijk的…
A. Fight the Monster Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/487/problem/A Description A monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attr…
题目链接: A. Fight the Monster time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster ea…
题目链接:Fight Against Traffic 题意:有n个点个m条双向边,现在给出两个点S和T并要增加一条边,问增加一条边且S和T之间距离不变短的情况有几种? 题解:首先dfs求一下S到其他点和T到其他点的最短路(好久不写有点手生@.@),然后遍历所有的建边的情况,假设在i和j两个点之间建边则要满足 ds[i] + 1 + dt[j] > ds[T] && ds[j] + 1 + dt[i] > ds[T]. #include<bits/stdc++.h>…
https://codeforc.es/gym/102222/problem/H 题意:有一堆怪兽,怪兽有HP和ATK.你有一个英雄,英雄每次先被所有怪兽打,然后打其中一个怪兽.打的伤害递增,第一次1,第二次2,以此类推. 为什么感觉是贪心呢?证明一波. 首先开始打一个怪兽肯定一直打到死为止.那么打死他要求的次数可以二分出来(其实暴力也可以).两只怪兽交换打的顺序会不会变好? 先打第一只怪兽: \(num_1*sumatk+num_2*(sumatk-atk_1)\) 先打第二只怪兽: \(nu…
传送门:http://codeforces.com/contest/918/problem/C 一个括弧串由字符‘(’和‘)’组成.一个正确的串可被递归地定义,定义如下: ①空串e是一个正确的串: ②若串s是一个正确的串,则串(s)也是一个正确的串: ③若串s.t均是正确的串,则串st也是一个正确的串. 对于一个由字符‘(’.‘)’和‘?’组成的串s,考虑其子串s.substr(i,j):将这个子串的符号‘?’置换为‘(’或‘)’,若置换后的串是一个正确的串,则原来的子串是一个完美的串.试统计串…
[题目链接]:http://codeforces.com/contest/787/problem/A [题意] 把b一直加a->得到x 把d一直加c->得到y 然后问你x和y可不可能有相同的值. 有的话,输出那个最小的; [题解] 等价于 令t=(b+u*a-d)%c==0 u为整数 这里如果b< d就swap(a,c),swap(b,d)就好; 然后如果t遇到了重复的值,就结束,往后都不可能了; 如果t中途变成0了,就输出那个u; [完整代码] #include <bits/st…
题目大意: n 只怪兽,每只的血量为 h[i] ,你的攻击力为 a ,你的对手攻击力为 b 打每只怪兽时,都是你先出手,然后你的对手出手,这样轮流攻击 如果是你给予了怪兽最后一击,你就能得到一分 你还有 k 次机会能让你的对手暂停行动一回合 问你最多能拿到多少分 解题思路: 记你加上你的对手两个人各攻击一次造成的伤害为 s=a+b 贪心可得,如果想节省那 k 次机会,应该和对手一起把怪兽耗到只剩一点血,即能在最后一回合杀死的情况时 即怪兽减去的血量为 s 的倍数,表示经过了这么多回合后,怪兽的血…
题目链接:http://codeforces.com/contest/488 A. Giga Tower Giga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from  - 8 888 888 888 to 8 888 888 888. In particular, there is floor 0 between floor  - 1 and…
Fight the Monster CodeForces - 487A A monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF). During the ba…
Python之中,一切皆对象. 本文分为4部分: 1. 面向对象:初识 2. 面向对象:进阶 3. 面向对象:三大特性----继承,多态,封装 4. 面向对象:反射 0. 楔子 面向过程和面向对象的是两种思路: 面向过程是流水线,闷着头一口气写下来就行; 面向对象,感觉自己像是个上帝,先构思好,然后再去写,这也是我们写程序时候要做到的. 例子如下: #面向过程,函数: def login(): pass def regisgter(): pass def func1(): pass def fu…
B. The Monster and the Squirrel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/B Description Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her…
918C - The Monster 思路1: 右键在新窗口打开图片 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset(a,b,sizeof(a)) int main(){ ios::sync_with_stdio(false); cin.tie(); string s; cin>>s; ; ;i<…
E. The Last Fight Between Human and AI 题目连接: http://codeforces.com/contest/676/problem/E Description 100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth!…
链接 Codeforces 676E The Last Fight Between Human and AI 题意 给一个多项式,有些系数不确定.人和机器轮流填系数,系数可以是任何数,问是否能使得最后的多项式整除 x-k 思路 整除x-k就等价 x=k时,多项式为0. 系数可以是任何数的话就能得到任何结果,只要人是否是填最后一个就行. 另外分 k=0 和 k<>0两种情况考虑. 代码 #include <iostream> #include <cstdio> #incl…
You play a computer game. In this game, you lead a party of mm heroes, and you have to clear a dungeon with nn monsters. Each monster is characterized by its power aiai. Each hero is characterized by his power pipi and endurance sisi. The heroes clea…
There are nn monsters standing in a row numbered from 11 to nn . The ii -th monster has hihi health points (hp). You have your attack power equal to aa hp and your opponent has his attack power equal to bb hp. You and your opponent are fighting these…
题目链接:http://codeforces.com/contest/592/problem/B 题目分类:数学,找规律 题目分析:重要的是画图找规律   代码: #include<bits/stdc++.h> using namespace std; #define LL __int64 int main() { LL n; cin>>n; cout<<(n-)*(n-)<<endl; ; }…
B. The Monster and the Squirrel time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feed…
题目链接:http://codeforces.com/contest/918/problem/C 题目大意:给你一串字符串,其中有'('.')'.'?'三种字符'?'可以当成'('或者')'来用,问该字符串中有多少子串符合括号匹配的规则. 解题思路:根据括号匹配原始版进行改进,设置high和low分别表示未匹配左括号数的上限和下限,当遇到'('时low++,high++,遇到')'时low--,high--,遇到'?'时由于既可以表示'('又可以表示')',所以high++,low--. 原始版…
C. The Monster time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn t…
As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside D…
D. Yet Another Monster Killing Problem You play a computer game. In this game, you lead a party of…
A. The Monster time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately…
D : Fight with Monsters 题目大意 : 有一组数,每个值对应着一个怪物的 hp 值,现在有两个人,一个自己一个对手,每个人有一个攻击值, 两个人轮流攻击怪物,如果是自己将怪物先打倒,则 + 1 分,反之则不加,在攻击过程中,自己可以使用 特权,轮到对手的时候自己攻击将怪物打倒,从而使得自己能够加分,特权是有限制的,用完特权后剩下的就只 能听天由命了,问在这种情况下自己最多可以得到多少分 ? 析题得说 : 我们知道,两个人是轮流进行的,所以我们通过看能进行几轮,最后该自己的时…
链接 大意:给定字符串, 只含'(',')','?', 其中'?'可以替换为'('或')', 求有多少个子串可以的括号可以匹配 (不同子串之间独立) 记$s_($为'('个数, $s_)$为')'个数. 一个括号串匹配等价于长度为偶数, 且任意一个前缀中$s_( \ge s_)$,任意一个后缀中$s_) \ge s_($. 对前缀后缀分别暴力判断即可 #include <iostream> #include <algorithm> #include <cstdio> #…
扩欧,a+bx=c+dx,输出x>=0且y>=0,且a+bx最小的解. 要注意不能只保证x非负,还得看看能否保证y也非负. #include<cstdio> #include<iostream> using namespace std; typedef long long ll; ll a,b,c,d; void exgcd(ll a,ll b,ll &d,ll &x,ll &y) { if(!b) { d=a; x=1; y=0; } else…
题意 给一个序列,包含(,),?,?可以被当做(或者),问你这个序列有多少合法的子序列. 分析 n^2枚举每一个子序列,暂时将每个?都当做右括号,在枚举右端点的时候同时记录两个信息:当前左括号多余多少个(top),已经将多少个?变成了右括号(cnt). 如果当前是(,top++. 如果当前是),top--. 如果当前是?,top--,cnt++; 如果top<0,我们需要判断一下当前还有没有之前被当做右括号的?,如果有的话,我们将其变为左括号,如果没有的话,意味着可以跳出循环了,之后都不会再合法…
Discription Little town Nsk consists of n junctions connected by m bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any other junction by th…