摘要: 题目:Y原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4705分析:树形dp的思想,枚举中间点。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define maxn 10000510 #define LL __int6411 #pragma comment(linker, "/STACK:16777216")12 vectore[maxn];13 LL ans,sum 阅读全文
posted @ 2013-09-15 22:42 EtheGreat 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题目:Sum原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4704分析:实际上就是求2^(n-1)mod(1e9+7).因为2与1e9+7互素,所以可以用费马小定理。参考:http://baike.baidu.com/view/263807.htm(a,p)=1,则a^(p-1)Ξ1(modp).可得:2^(n-1)%mod=2^((n-1)%(mod-1)) %mod;证明:(n-1)=(n-1)%mod+k*(mod-1).则:2^(n-1)=2^((n-1)%(mod-1)) * 2^(k*(mod-1));可知结论成立。 1 #inclu 阅读全文
posted @ 2013-09-15 21:57 EtheGreat 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目:Good Numbers原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722分析:找规律,每十个数中有一个。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define maxn 100005 8 #define LL __int64 9 int main()10 {11 int T,cas=1;12 cin>>T;13 LL l,r;14 while(T--)15 {16 ... 阅读全文
posted @ 2013-09-15 20:55 EtheGreat 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 题目:Minimum palindrome原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4731分析:找规律。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int n,m; 8 9 int main()10 {11 int T,cas=1;12 cin>>T;13 while(T--)14 {15 scanf("%d%d",&m,&n);16 printf("Case... 阅读全文
posted @ 2013-09-15 20:35 EtheGreat 阅读(158) 评论(0) 推荐(0) 编辑