写一下二叉树 推一下公式就出来了, 注意取模时的输出形式 #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; typedef long long LL; , INF = ; LL n, k; LL qp(LL a, LL b) { LL res = ; while(b) { ) res = res * a % MOD; a = a * a % MOD; b >&g…
Nastya and a Wardrobe time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dress…
Nastya received a gift on New Year - a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month). Unfortunately, right a…
题意:给出两个n*m的矩阵,每次操作可以让一个正方形矩阵行列交换.问,在无限次操作下,第一个矩阵能否变成第二个矩阵 分析:先把操作限定在2*2的矩阵中.这样对角线上的元素就可以随意交换.也就是说,如果给相邻的元素随意的交换次数,那么一个长度为n的数列可以得到任何顺序. 然后把操作放大,发现不在一个对角线上的元素无论如何也是无法交换位置的. ac代码: #include<bits/stdc++.h> using namespace std; const int maxn=505; int num…
You are given an integer sequence 1,2,…,n1,2,…,n. You have to divide it into two sets AAand BB in such a way that each element belongs to exactly one set and |sum(A)−sum(B)||sum(A)−sum(B)| is minimum possible. The value |x||x| is the absolute value o…
C. Do you want a date? time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immedi…