比赛的时候遇到这种题,只能怪自己高数学得不好,看着别人秒。。。。

由4种字母组成,A和C只能出现偶数次。

构造指数级生成函数:(1+x/1!+x^2/2!+x^3/3!……)^2*(1+x^2/2!+x^4/4!+x^6/6!……)^2.

前面是B和D的情况,可以任意取,但是相同字母一样,所以要除去排列数。后者是A和C的情况,只能取偶数个情况。

根据泰勒展开,e^x在x0=0点的n阶泰勒多项式为 1+x/1!+x^2/2!+x^3/3!……

而后者也可以进行调整,需要把奇数项去掉,则e^(-x)的展开式为1-x/1!+X^2/2!-X^3/3!……

所以后者可以化简为(e^x+e^(-x))/2。则原式为 (e^x)^2   *  ((e^x*e^(-x))/2)^2

整理得到e^4x+2*e^2x+1。

又由上面的泰勒展开

e^4x = 1 + (4x)/1! + (4x)^2/2! + (4x)^3/3! + ... + (4x)^n/n!;

e^2x = 1 + (2x)/1! + (2x)^2/2! + (2x)^3/3! + ... + (2x)^n/n!;

对于系数为n的系数为(4^n+2*2^n)/4=4^(n-1)+2^(n-1);

快速幂搞之。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<cmath>
#define LL long long
#define MOD 100
#define eps 1e-6
#define N 100010
#define zero(a) fabs(a)<eps
using namespace std;
int PowMod(int a,LL b){
int ret=;
while(b){
if(b&)
ret=(ret*a)%MOD;
a=(a*a)%MOD;
b>>=;
}
return ret;
}
int main(){
int t;
while(scanf("%d",&t)!=EOF&&t){
int cas=;
LL n;
while(t--){
scanf("%I64d",&n);
printf("Case %d: %d\n",++cas,(PowMod(,n-)+PowMod(,n-))%MOD);
}
printf("\n");
}
return ;
}

最新文章

  1. 浅析String、StringBuffer、StringBuilder的区别以及性能区别
  2. Oracle 11g 数据库自动备份执行脚本
  3. 使用thinkphp连接sqlserver数据库时提示“系统不支持:sqlsrv”
  4. 数据结构-多级指针单链表(C语言)
  5. scrapy shell 中文网站输出报错.记录.
  6. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(2)-easyui构建前端页面框架[附源码]
  7. 首页 导航栏隐藏 下一级页面显示,pop回来遇到的问题
  8. Spark SQL Catalyst源代码分析之TreeNode Library
  9. String,StringBuffer与StringBuilder差异??
  10. Spring实战——缓存
  11. SSH key introduction
  12. 基于flash的web视频对讲直播测试
  13. Codeforces Round #525 (Div. 2) D. Ehab and another another xor problem(待完成)
  14. linux bash timeout
  15. win 10 kms 激活 后 火狐 上 https 网站 报错
  16. js对象(BOM部分/DOM部分)
  17. Nginx 配置 Location 规则优先级问题
  18. Spring中IOC与DI的的区别
  19. sicily 1009. Mersenne Composite N
  20. BZOJ4567 [Scoi2016]背单词 【trie树 + 贪心】

热门文章

  1. download &amp; excel &amp; blob
  2. Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 3. 循环
  3. python自动化之爬虫原理及简单案例
  4. 一本通1628X-factor Chain
  5. 【设计模式】—— 桥接模式Bridge
  6. MT【110】巧设法向量解决距离问题
  7. C/C++ Bug记录
  8. 【BZOJ1560】[JSOI2009]火星藏宝图(贪心,动态规划)
  9. 洛谷P2469 星际竞速
  10. win下jdk7环境变量的配置