题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4990 题意 初始的ans = 0 给出 n, m for i in 1 -> n 如果 i 为奇数 ans = (ans * 2 + 1) % m 反之 ans = ans * 2 % m 思路 如果我们只计算 偶数项 那么递推公式就是 ans[n] = 4 * ans[n - 2] + 2 如果 n 是偶数 那么刚好 就按这个公式推 第 n / 2 项 如果 n 是奇数 那么就是 第 [ n /…
快速幂 #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std; long long n,MOD; long long cal(long long a,long long b,long long mod) { ; ) { ==) c=(c*a)%mod,b--; ; } return…
思路: 如图找到推导公式,然后一通乱搞就好了 要开long long,否则红橙作伴 代码: #include<set> #include<cstring> #include<cstdio> #include<algorithm> #define ll long long const int maxn = 3; const int MOD = 1000000000+7; const int INF = 0x3f3f3f3f; using namespace s…
Problem Description Read the program below carefully then answer the question.#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio>#include<iostream>#include <cstring>#include <cmath>#include <algori…
Reading comprehension Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1270 Accepted Submission(s): 512 Problem Description Read the program below carefully then answer the question.#pragma co…
题目链接: Reading comprehension Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description Read the program below carefully then answer the question.#pragma comment(linker, "/STACK:1024000000,1024000000&quo…