上一页 1 2 3 4 5 6 ··· 9 下一页
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1056题目:大小写切换分析:以前这种问题我都是用dp写的,最近学到了一种更简洁的方法,特此记录下来! 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define maxn 200000510 #define LL long long11 int T,n;12 char s[220];13 int main()14 {15 scanf(" 阅读全文
posted @ 2013-12-12 23:29 EtheGreat 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1141分析:运用欧拉函数可解此题。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #define LL long long12 using namespace std;13 int T;14 int n;15 int gcd(int a,int b)16 {17 if(b==0)return a;18... 阅读全文
posted @ 2013-12-10 01:23 EtheGreat 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 题目:Park Visit原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4607分析:求树的直径。所谓树的直径,指的是一棵树里任意两点之间的最远距离。方法为选定一点,然后从该点bfs,则最后一个出栈的点必为直径的一端,然后以该点为起点bfs,求出直径即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define maxn 10000510 int T,n,m;11 vectorg[ma 阅读全文
posted @ 2013-11-02 15:18 EtheGreat 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 题目:Revenge of Fibonacci原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4099分析:字典树的应用。在求Fibonacci的前40位时,可以只记录下前60位,舍去后面的,这样不会因为进位而产生误差。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 6000005 9 using namespace std; 10 char s[44],s1[101],s2[101],s3[1... 阅读全文
posted @ 2013-10-05 20:54 EtheGreat 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 题目:Stone原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4764 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int main() 8 { 9 int n,k;10 while(scanf("%d%d",&n,&k)==2)11 {12 if(n==0&&k==0)break;13 if((n-1)%(k+1)==0)printf("Jiang\n");1 阅读全文
posted @ 2013-09-28 22:10 EtheGreat 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目:小希的迷宫原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1272分析:并查集的应用。判断有无环以及是否都在一个集合里即可! 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define maxn 100005 7 #define ll long long 8 #define inf 0x7fffffff 9 using namespace std;10 int fa[maxn],vis[maxn];11 void make_set()12 {13 for(int i... 阅读全文
posted @ 2013-09-28 21:29 EtheGreat 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 题目:Flyer原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4768分析:二分。只需要注意到最多只有一个为奇数,则可以首先求出学生获得的总的传单数,为奇数时,二分找到答案。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define LL long long 8 #define maxn 20005 9 struct N10 {11 LL now,lim,add;12 }p[maxn];13 int n;14 int ma... 阅读全文
posted @ 2013-09-28 19:31 EtheGreat 阅读(266) 评论(0) 推荐(1) 编辑
摘要: 题目:A Coin Problem原题链接:http://acm.uestc.edu.cn/problem.php?pid=1468分析:满足裴波纳契数列,打表找周期。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define mod 10000 8 int dp[15005]; 9 void F(int n)10 {11 dp[0]=1;dp[1]=2;12 for(int i=2;i<=n;i++)13 dp[i]=(dp[i-1]+dp[i-2])... 阅读全文
posted @ 2013-09-17 19:58 EtheGreat 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 题目:Easy math原题链接:http://acm.uestc.edu.cn/problem.php?pid=1548分析:费马小定理的应用。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define LL long long 7 const LL mod=1000000007; 8 LL pow_mod(LL a,LL b,LL m) 9 {10 if(b==0)return 1%m;11 LL temp=pow_mod(a,b>>1,m);12 temp=temp*t... 阅读全文
posted @ 2013-09-17 16:49 EtheGreat 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 题目: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) 编辑
上一页 1 2 3 4 5 6 ··· 9 下一页