D. Tricky Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/429/D Description Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The sele…
A. Calculating Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/486/problem/A Description For a positive integer n let's define a function f: f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) for a…
传送门:http://codeforces.com/contest/912/problem/A A. Tricky Alchemy time limit per test1 second memory limit per test256 megabytes Problem Description During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already…
题目链接:http://codeforces.com/problemset/problem/429/B 给你一个矩阵,一个人从(1, 1) ->(n, m),只能向下或者向右: 一个人从(n, 1) ->(1, m),只能向上或者向右.必须有一个相遇点, 相遇点的值不能被取到, 问两个人能得到的最大路径和是多少? dp[i][j]:表示从一个点出发的最大值:先预处理从(1,1) (1,m) (n,1) (n,m)四个点出发的4个dp最大值.然后枚举所有的点,但是这个点不能在边缘,考虑枚举点不够…
题目:http://codeforces.com/problemset/problem/429/B 第一个人初始位置在(1,1),他必须走到(n,m)只能往下或者往右 第二个人初始位置在(n,1),他必须走到(1,m)只能往上或者往右 每个点都有个权值,要求两个人中间相遇一次且只有一次,相遇的那个点的权值不算,两个人的速度可以不一样,然后求出最大值是多少 思路:他的要求是相遇一次且只有一次,那么画几个图其实就只有两个情况了(这图是借了一位大佬的,[小声bb]) 既然知道了这个图分为了这四个区域,…
题目链接:www.codeforces.com/problemset/problem/486/A题意:求表达式f(n)的值.(f(n)的表述见题目)C++代码: #include <iostream> using namespace std; long long f(long long n) { == ) ; else - n; } int main() { long long n; cin >> n; cout << f(n) << endl; ; } C…
题目链接: http://codeforces.com/contest/429/problem/B B. Working out time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym w…
C. Xor-tree Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/430/problem/C Description Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolu…
B. Balls Game Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/430/problem/B Description Iahub is training for the IOI. What is a better way to train than playing a Zuma-like game? There are n balls put in a row. Each ball i…
A. Points and Segments (easy) Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/430/problem/A Description Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on…
B. Working out time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where the…
Calculating Function time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For a positive integer n let's define a function f: f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) f…
A. Calculating Function   For a positive integer n let's define a function f: f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) for a given integer n. Input The single line contains the positive integer n (1 ≤ n ≤ 1015). Output Print…
Ayoub thinks that he is a very smart person, so he created a function f(s)f(s) , where ss is a binary string (a string which contains only symbols "0" and "1"). The function f(s)f(s) is equal to the number of substrings in the string s…
暴利搜索即可 #include <iostream> #include <vector> #include <iostream> using namespace std; int main(){ int n,k,x; cin >> n >> k >> x; vector<int> c(n); ; i < n; ++ i) cin >> c[i]; ; ; i < n ; ++ i){ ]){ , r…
水到家了 #include <iostream> #include <vector> #include <algorithm> using namespace std; struct Point{ int index, pos; Point(, ){ index = index_; pos = pos_; } bool operator < (const Point& a) const{ return pos < a.pos; } }; int ma…
题目链接 题意: 一个n*m的矩阵,每一个方格有一个非负数,如今选择两条线路:一个左上到右下,一个左下到右上,且仅仅能有一个公共点. 求两个线路上数的最大值(公共点不算) 分析: 仅仅有两种情况,dp就可以. 记两个线路为1和2.考虑一个公共点.1为左进右出.2为下进上出.1上进下出,2为左进右出 const int MAXN = 1005; int lu[MAXN][MAXN], ld[MAXN][MAXN]; int ru[MAXN][MAXN], rd[MAXN][MAXN]; int i…
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/yew1eb/article/details/25609981 A Points and Segments (easy)  智商题.(智商捉急~) /*********************************************************** *分析:仅仅要按Xi从小到大染成1010101010... , *1.0间隔的的序列就能保证对于随意区间[l, r]中1的个数和0的…
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012476429/article/details/25607945 题目链接 题意: 给一棵树n个节点,1为根节点.操作为,选定一个节点x.当前值取反,x的孙子,孙子的孙子.. . 均取反 如今告诉初始时每一个点的值和最后每一个点的目标值.求操作次数最少时须要选择那些节点) 分析: 深度浅的点一定是受影响最小的(根节点仅仅受自己的影响).所以从根依次向下递推处理就可以 const int MAX…
题目链接 题意: n个节点,给定每一个节点的子树(包含自己)的节点个数.每一个节点假设有子节点必定大于等于2.求这种数是否存在 n (1 ≤ n ≤ 24). 分析: 用类似DP的思路,从已知開始.这题的已知显然是叶子,那么从叶子開始考虑. 如今给一个节点,子树节点数为x.那么从叶子中找x-1个就可以.之后再来一个y.不放设y <= x,这时候就有两种选择,尽量选1或者尽量选x.分析一下:首先明确一点.无论怎样选择,之后能用的点的和是一定的.假设尽量选小的,那么会使得选过之后的点数小的比較少.假…
Codeforces Round #277 (Div. 2) A. Calculating Function time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For a positive integer n let's define a function f: f(n) =  - 1 + 2 - 3 + .. + ( - 1)n…
Codeforces Round #456 (Div. 2) A. Tricky Alchemy 题目描述:要制作三种球:黄.绿.蓝,一个黄球需要两个黄色水晶,一个绿球需要一个黄色水晶和一个蓝色水晶,一个蓝球需要三个蓝色水晶,现有\(A\)个黄色水晶和\(B\)个蓝色水晶,要制作\(x\)个黄球,\(y\)个绿球和\(z\)个蓝球,还需要多少个水晶? solution \(max(0, x*2+y-A)+max(0, z*3+y-B)\) 时间复杂度:$ O(1) $ B. New Year's…
门户:Codeforces Round #277 (Div. 2) 486A. Calculating Function 裸公式= = #include <cstdio> #include <cstring> #include <algorithm> using namespace std ; typedef long long LL ; LL n ; int main () { while ( ~scanf ( "%I64d" , &n )…
/* CodeForces 840A - Leha and Function [ 贪心 ] | Codeforces Round #429 (Div. 1) A越大,B越小,越好 */ #include <bits/stdc++.h> using namespace std; const int N = 2e5+5; int a[N], b[N], c[N], n; int aa[N], bb[N]; bool cmp1(int x, int y) { return a[x] > a[y…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…
 Codeforces Round #665 (Div. 2)  A. Distance and Axis 如果\(B\)在\(O\)左边,那么只能是定值\(OA\) 如果\(B\)在\(OA\)中间,那么必然小于等于\(OA\)且奇偶性和\(OA\)相同 \(B\)在\(A\)右边的情况显然不如\(B\)和\(A\)重合 所以分\(k\le n\)和\(k>n\)分类讨论即可 view code #pragma GCC optimize("O3") #pragma GCC op…
Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3") //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std; function<void(void)> __…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…