CodeForces 32C. Flea 水题】的更多相关文章

C. Flea time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It is known that fleas in Berland can jump only vertically and horizontally, and the length of the jump is always equal to s centime…
最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------只建立源文件无法调试,需要建立一个工程后才能调试 3.设置断点后,调试不会停止------开启-g模式且工程要建立在一个没有中文名的文件夹下 4.调试中如何查看变量------打开debug中的watch,右键编辑界面的变量可以选择添加变量 水题来源---codeforces(hzwer神犇刷的水题…
题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring…
题目链接:http://codeforces.com/problemset/problem/705/B 题意略解: 两个人玩游戏,解数字,一个数字可以被分成两个不同或相同的数字 (3可以解成 1 2),最小1不能再解 示例1: 第一把 当前1号玩家开始解数字 1,不能解, 则2号赢 输出2 第二把 当前数字为 1 2, 1号玩家直接对 2 进行解 解成 1 1,数字为 1 1 1,2号玩家无解,1号赢 第三把 当前数字为 1 2 3,一号玩家先对 2 解,解成 1 1,数字为 1 1 1 3,2…
题目链接:http://codeforces.com/problemset/problem/327/B 这道题目虽然超级简单,但是当初我还真的没有想出来做法,囧,看完别人的代码恍然大悟. #include <cstdio> #include <cstdlib> #include <cmath> int main(void) { int n; scanf("%d", &n); ; i <= n+n; ++i) { printf("…
A. Puzzles Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/337/A Description The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to p…
题意:给定 n 堆数,然后有 m 个话询问,问你在哪一堆里. 析:这个题是一个二分题,但是有一个函数,可以代替写二分,lower_bound. 代码如下: #include<bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 1e5 + 5; int a[maxn]; int main(){ int n, m; cin >> n; for(int i = 1; i <= n; +…
CodeForces - 682B Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of elements in the Alyona's array. The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the ar…
题目链接:http://codeforces.com/problemset/problem/32/C 本文链接:http://www.cnblogs.com/Ash-ly/p/5513436.html 题意: 给你一个M*N的方格,有一个青蛙每次只能跳S步,问能够跳最多次数的起点有多少个. 思路: 首先,第一个格子肯定是可以作为起点的,那么往下能跳的点数为(M - 1) / S +1,往右能跳的点数为(N - 1) / S +1,这些点又都可以各自作为起点,所以假设以第一个格子为起点那么起点的个…
题意:给定 n 个桔子的大小,一个杯子的容积,一个最大限度,挨着挤桔子汁,如果大小大于限度,扔掉,如果不杯子满了倒掉,问你要倒掉多少杯. 析:直接按要求模拟就好,满了就清空杯子. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath&g…
题意:给定n个城市,其中有k个有仓库,问你在其他n-k个城市离仓库的最短距离是多少. 析:很容易想到暴力,并且要想最短,那么肯定是某一个仓库和某一个城市直接相连,这才是最优,所以只要枚举仓库,找第一个城市,然后更新答案即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib&g…
B - B Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1338 Description In this problem you are given two names, you have to find whether one name is hidden into another. The restrictions are:…
题目大意:在图中找到一个字符可以围成一个环(至少有环四个相同元素) 题目思路:对当前点进行搜索,如果发现可以达到某个已经被查找过的点,且当前点不是由这个点而来,则查找成功. #include<cstdio> #include<stdio.h> #include<cstdlib> #include<cmath> #include<iostream> #include<algorithm> #include<cstring>…
A. Arrays time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given two arrays A and B consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose kn…
反演一下可以得到$b_i=\sum\limits_{d=1}^i{\mu(i)(\lfloor \frac{i}{d} \rfloor})^n$ 整除分块的话会T, 可以维护一个差分, 优化到$O(nlogn+klogk)$ #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map>…
大意: 给定树, 每个节点有一个字母, 每次询问子树$x$内, 所有深度为$h$的结点是否能重排后构成回文. 直接暴力对每个高度建一棵线段树, 查询的时候相当于求子树内异或和, 复杂度$O((n+m)log(n+m))$ 看了别人题解后发现有简单做法, 高度相同的点在每个子树内的dfs序一定相邻, 直接维护每一层的异或和, 每次二分出该层属于$x$的子树的一段区间即可. 放一下线段树暴力的代码 #include <iostream> #include <algorithm> #in…
大意: 给定排列p, 0/1序列b, 有n个烤串, 每秒钟第i串会移动到$p_i$, 若$p_i$为1则翻面, 可以修改b和p, 求最少修改次数使得每串在每个位置正反都被烤过. 显然只需要将置换群合并为1个即可, 并且序列b中1的个数要为奇数. 考虑合并置换群的花费, 若置换群初始为1个则花费0, 否则为置换群的个数. #include <iostream> #include <algorithm> #include <math.h> #include <cstd…
题意:两个人有n1,n2个球,然后分别最多拿出 k1,k2个球,然后扔掉,谁先拿完谁输. 析:很简单么,每人都足够聪明,就每次扔一个好了,那么,谁的球多,谁就能赢呗,如果相等,那么第一个扔的输. 代码如下: #include <iostream> #include <cstdio> using namespace std; int main(){ int n, m, k, l; cin >> n >> m >> k >> l; if(…
while(t--) 最后结果t=-1 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #include <stack> using namespace std; #define MEM(a,b)…
这道题有个需要注意的地方,就是范围大小 2^16 = 65535,2^32 = 65535(10^4),2^16 = 4294967295(10^9),2^64=9223372036854775807(10^18) 这道题范围到10^9,3次方就超过了long long,所以可以用除法作为判定条件 #include <iostream> #include <string> #include <cstring> #include <cstdlib> #incl…
题意:给定一个键盘,然后一行字母,和一个字符,代表把那一行字母在键盘上左移还是右移一位. 析:没什么好说的,直接暴力就好. 代码如下: #include<bits/stdc++.h> using namespace std; typedef long long LL; char s1[] = "qwertyuiop"; char s2[] = "asdfghjkl;"; char s3[] = "zxcvbnm,./"; char s…
A. Bits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Let's denote as  the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple…
题意:给定 n 个密码,你要按长度不递减的顺序进行尝试,问你最多和最少试多少次可能找出密码,每尝试 k 次错误的,就要等5秒. 析:我们只要把长度全都统计下来,然后从1开始去找目标长度,最少的就是正好到目标长度,最多的就是把目标长度恰好试完. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <…
Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each m…
题目大意:给你几个数,这些数里面只有0或1,你有两种操作:1.把一段区域内的所有数前后交换位置.2.把一段区域内所有数取反.(区域可大可小,可以是所有数也                       可以只有一个数).两个操作各有它的代价,你操作一次就要消耗一次代价,求把所有数都变成1所需要的最小代价. 输入:第一行输入n , ab, c :表示有n个数,操作1代价b,操作2代价c:     第二行输入n个数,就是你要操作的数组. 输出:一行,输出最小代价. 题目分析: 1.如何运用操作1 :…
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; ; const int INF = 0x3f3f3f3f;…
题目传送门 /* 水题:一开始看错题意,以为是任意切割,DFS来做:结果只是在中间切出一段来 判断是否余下的是 "CODEFORCES" :) */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <algorithm> #include <cmath> #include <set>…
题目链接:http://codeforces.com/problemset/problem/328/B 水题~ #include <cstdio> #include <cstdlib> #include <cstring> ], a[]; ], c[]; int main(void) { //freopen("in.txt", "r", stdin); scanf("%s%s", n, a); int len1…
B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance betwee…
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to becom…