随笔分类 -  ACM--数论

摘要:String changeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 802Accepted Submission(s): 370Problem DescriptionIn this problem you will receive two strings S1and S2that contain only lowercase letters.Each time you can swap any two characters of S1. 阅读全文
posted @ 2013-07-20 10:20 剑不飞 阅读(200) 评论(0) 推荐(0)
摘要:2013暑期多校联合训练——80+高校,300+队伍,10000元奖金,敬请期待~CardTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 889Accepted Submission(s): 517Problem DescriptionBearchild is playing a card game with himself. But first of all, he needs to shuffle the cards. His strate 阅读全文
posted @ 2013-07-20 10:16 剑不飞 阅读(150) 评论(0) 推荐(0)
摘要:整数对Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2109Accepted Submission(s): 700Problem DescriptionGardon和小希玩了一个游戏,Gardon随便想了一个数A(首位不能为0),把它去掉一个数字以后得到另外一个数B,他把A和B的和N告诉了小希,让小希猜想他原来想的数字。不过为了公平起见,如果小希回答的数虽然不是A,但同样能达到那个条件(去掉其中的一个数字得到B,A和B之和是N),一样算小希胜 阅读全文
posted @ 2013-06-16 16:48 剑不飞 阅读(222) 评论(0) 推荐(0)
摘要:The minimum square sumTime Limit 1000msMemory Limit 65536Kdescription Given a prime p (p #include #include #include #include using namespace std; int main() { long long p; while (cin>>p) { if (p==2) cout << "2" << endl; else if((p-3)%4==0) cout << 2*p*p << end 阅读全文
posted @ 2013-05-05 14:36 剑不飞 阅读(264) 评论(0) 推荐(0)
摘要:Beef McNuggetsHubert ChenFarmer Brown's cows are up in arms, having heard that McDonalds is considering the introduction of a new product: Beef McNuggets. The cows are trying to find any possible way to put such a product in a negative light.One strategy the cows are pursuing is that of `inferio 阅读全文
posted @ 2013-03-26 10:45 剑不飞 阅读(271) 评论(0) 推荐(0)
摘要:D -SaviorTime Limit:4000MSMemory Limit:262144KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeCodeForces 60DDescriptionMisha decided to help Pasha and Akim be friends again. He had a cunning plan — to destroy all the laughy mushrooms. He knows that the laughy mushrooms can easily burst when th 阅读全文
posted @ 2013-03-22 14:36 剑不飞 阅读(234) 评论(0) 推荐(0)
摘要:Closed FencesA closed fence in the plane is a set of non-crossing, connected line segments with N corners (3 #include #include #include using namespace std; const double ex=1e-10; const int mm=2100; class _point { public:double x,y; _point(double xx,double yy){x=xx;y=yy;} _point(){} }; class ... 阅读全文
posted @ 2013-03-19 10:50 剑不飞 阅读(374) 评论(0) 推荐(0)
摘要:E -Square Equation RootsTime Limit:5000MSMemory Limit:262144KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeCodeForces 50EDescriptionA schoolboy Petya studies square equations. The equations that are included in the school curriculum, usually look simple:x2 + 2bx + c = 0whereb,care natural nu 阅读全文
posted @ 2013-03-17 17:29 剑不飞 阅读(238) 评论(0) 推荐(0)
摘要:D -NotepadTime Limit:2000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeCodeForces 17DDescriptionNick is attracted by everything unconventional. He doesn't like decimal number system any more, and he decided to study other number systems. A number system with basebcau 阅读全文
posted @ 2013-03-14 12:15 剑不飞 阅读(267) 评论(0) 推荐(0)
摘要:Electric FenceDon PieleIn this problem, `lattice points' in the plane are points with integer coordinates.In order to contain his cows, Farmer John constructs a triangular electric fence by stringing a "hot" wire from the origin (0,0) to a lattice point [n,m] (00), and then back to the 阅读全文
posted @ 2013-03-13 16:17 剑不飞 阅读(257) 评论(0) 推荐(0)
摘要:Geometric sumCompute(a+a2+…an)modm.InputThree integersa,n,m.(1≤a,n,m≤1018)OutputThe only integer denotes the result.Sample input2 2 1000000000Sample output6 思路;看代码吧#include #include using namespace std; long long c,x,n; long long mul(long long a,long long b)///(a*b)%c { long long ret=0; a%=c;b%=c;.. 阅读全文
posted @ 2013-03-09 14:23 剑不飞 阅读(249) 评论(0) 推荐(0)
摘要:取石子游戏Time Limit:1000MSMemory Limit:10000KTotal Submissions:29959Accepted:9818Description有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,00 阅读全文
posted @ 2013-02-26 20:54 剑不飞 阅读(360) 评论(0) 推荐(0)
摘要:Divisor counting (Easy)Let σ(n)denote the number of divisors of n.Compute σ(1)+σ(2)+⋯+σ(n).InputAn integer n.(1≤n≤108)OutputThe sum.Sample input5Sample output10思路:计算 [1, X]区间内所有数字的因子个数之和这个等价于X / 1 + X / 2 + ... + X / X, 这里注意是整除,直接暴力(O(X)超时),所以就要分段求; 例如:X/[i………j]==X[k](i #include using namespace std; 阅读全文
posted @ 2013-02-08 13:27 剑不飞 阅读(157) 评论(0) 推荐(0)
摘要:XorFor given multisets AandB, find minimum non-negative xwhichA⊕x=B.Note that for A={a1,a2,…,an},A⊕x={a1⊕x,a2⊕x,…,an⊕x}.⊕stands for exclusive-or.InputThe first line contains a integer n, which denotes the size of set A(also for B).The second line contains nintegersa1,a2,…,an, which denote the set A. 阅读全文
posted @ 2013-02-07 21:00 剑不飞 阅读(185) 评论(0) 推荐(0)
摘要:Square freeTest whether nis square free. nis square free if and only if for all p>1,p2is not divisors of n.InputThe first line contains an integer t, the number of test cases.The following nlines, each contains an integer n.(1≤t≤102,1≤n≤1018)OutputPrint "Yes" if nis square free, or &quo 阅读全文
posted @ 2013-02-07 20:14 剑不飞 阅读(205) 评论(0) 推荐(0)