09 2013 档案

摘要:题目: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 阅读(140) 评论(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 阅读(202) 评论(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 阅读(275) 评论(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 阅读(99) 评论(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 阅读(153) 评论(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 阅读(179) 评论(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 阅读(199) 评论(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 阅读(150) 评论(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 阅读(164) 评论(0) 推荐(0)
摘要:原题链接:分析:求最小周期的应用。 1 #include 2 #include 3 #include 4 #include 5 #define maxn 1005 6 using namespace std; 7 char s[maxn]; 8 int next[maxn],len; 9 void get_next()10 {11 int i=0,j=-1;len=strlen(s);12 next[0]=-1;13 while(i<len)14 {15 if(j==-1||s[i]==s[j]){16 i++,j++;1... 阅读全文
posted @ 2013-09-08 19:21 EtheGreat 阅读(155) 评论(0) 推荐(0)
摘要:原题链接:http://acm.uestc.edu.cn/problem.php?pid=1655分析:注意可能会反向。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define maxn 1005 7 #define inf 0x7fffffff 8 using namespace std; 9 int l[maxn],r[maxn];10 int dis1[maxn];//clockwise11 int dis2[maxn];//ante-clockwise12 int ans[maxn];13 int main()1 阅读全文
posted @ 2013-09-08 18:40 EtheGreat 阅读(133) 评论(0) 推荐(0)
摘要:一:埃拉托斯尼斯筛法. 1 #define maxn 1000000 2 bool isPrime[maxn+10]={true}; 3 int prime[maxn],k=0; 4 void selPrime() 5 { 6 isPrime[0]=isPrime[1]=false; 7 for(int i=2;i<=maxn;i++) 8 { 9 if(isPrime[i])10 {11 prime[k++]=i;12 ... 阅读全文
posted @ 2013-09-05 10:10 EtheGreat 阅读(176) 评论(0) 推荐(0)
摘要:原题链接:http://acm.nefu.edu.cn/JudgeOnline/problemshow.php?problem_id=117分析:设数为N,则其位数为(int)lg(N)+1;log(10)=ln(10);素数定理:令Pn表示 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int main() 8 { 9 int n;10 double e=2.71828;11 while(cin>>n)12 {13 double ans=double(n... 阅读全文
posted @ 2013-09-04 23:39 EtheGreat 阅读(228) 评论(0) 推荐(0)
摘要:原题链接:http://acm.uestc.edu.cn/problem.php?pid=1300分析:dp,最长公共上升子列。对于两个序列num1[maxn],num2[maxn]:如果num1[i]==num2[j],dp[i][j]=max(dp[i][k])+1;(knum2[k]).否则dp[i][j]=dp[i-1][j]. 1 #include 2 #include 3 #include 4 #include 5 #define maxn 1005 6 using namespace std; 7 int n1,n2,ans; 8 int num1[maxn],num2[maxn 阅读全文
posted @ 2013-09-02 17:42 EtheGreat 阅读(160) 评论(0) 推荐(0)