Codeforces 1299A/1300C - Anu Has a Function】的更多相关文章

题目大意: 给定一种函数F(x,y)=(x|y)-y,| 即按位或运算 给定一个长度为n的数组a[1],a[2],a[3]...a[n] 可以重新排列数组a,使得 F ( ...... F ( F ( a[1] , a[2] ) , a[3] ) ...... , a[n] ) 最后得到的答案最大 问这样的一个排列(答案不唯一输出任意一个) 解题思路: 首先拿到这种函数,可以去找他的规律 举例两个二进制的数 11111 01010 这两个数先进行取或运算,得到 11111 再减去第二个数,得到…
Anu has created her own function ff : f(x,y)=(x|y)−y where || denotes the bitwise OR operation. For example, f(11,6)=(11|6)−6=15−6=9. It can be proved that for any nonnegative numbers xx and yy value of f(x,y)f(x,y) is also nonnegative. She would lik…
D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, n and x find t…
题目链接:http://codeforces.com/problemset/problem/678/D 简单的矩阵快速幂模版题 矩阵是这样的: #include <bits/stdc++.h> using namespace std; typedef __int64 LL; struct data { LL mat[][]; }; LL mod = 1e9 + ; data operator *(data a , data b) { data res; ; i <= ; ++i) { ;…
A. Little Elephant and Function time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant enjoys recursive functions. This time he enjoys the sorting function. Let a is a permuta…
  D. Iterated Linear Function time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For…
D. Iterated Linear Function time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x))for n > 0. For the…
数论题还是好恶心啊. 题目大意:给你两个不超过1e12的数 x,y,定义一个f ( x, y ) 如果y==0 返回 0 否则返回1+ f ( x , y - gcd( x , y ) ); 思路:我们设gcd ( x , y) 为G,那么 设 x  = A*G,y = B*G,我们考虑减去多少个G时x y 的gcd会改变,我们设减去 k个G的时候 x和y 的gcd为改变,即 A*G 和 ( B - k ) * G 的 gcd 改变了,什么情况下会改变呢,就是A 和( B -  k )的gcd…
题库链接 https://codeforces.ml/contest/1300 A. Non-zero 一个数组,每次操作可以给某个数加1,让这个数组的积和和不为0的最小操作数 显然如果有0的话,必须操作一次,最后如果和还是为0的话,再操作一次 #include <bits/stdc++.h> using namespace std; #define mem(a,b) memset(a,b,sizeof(a)) #define pii pair<int,int> #define i…
记录 Codeforces 2019年12月19日到 2020年2月12日 的部分比赛题 Educational Codeforces Round 82 (Rated for Div. 2) D Fill The Bag 给出m(≤1e5)个盒子,盒子的大小是2的幂次.可以选择把一个盒子分成大小相同的两部分,问最少执行几次分盒子的操作,可以装满大小为n(≤1e18)的背包. 把n转化为二进制,代表可以由若干种2的幂次的盒子各一个装满.从小往大贪心地使用已有的盒子,不足时把第一个比它大的盒子分开.…