上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页
摘要: K尾相等数时间限制:3000 ms | 内存限制:65535 KB难度:1描述输入一个自然数K(K>1),如果存在自然数M和N(M>N),使得K^M和K^N均大于等于1000,且他们的末尾三位数相等,则称M和N是一对“K尾相等数”。下面请编程求出M+N最小的K尾相等数。输入第一行包含一个正整数T,Tint main(){ int T; scanf("%d",&T); while(T--) { int s[1010]={0}; int i,j,k,t,m; scanf("%d",&k); t=1;m=0; while(t 2 i 阅读全文
posted @ 2014-02-27 22:56 龙腾四海365 阅读(238) 评论(0) 推荐(0)
摘要: ACM数论总结http://blog.csdn.net/xieshimao/article/details/6425099断断续续的学习数论已经有一段时间了,学得也很杂,现在进行一些简单的回顾和总结。学过的东西不能忘啊。。。1、本原勾股数:概念:一个三元组(a,b,c),其中a,b,c没有公因数而且满足:a^2+b^2=c^2首先,这种本原勾股数的个数是无限的,而且构造的条件满足:a=s*t,b=(s^2-t^2)/2,c=(s^2+t^2)/2其中s>t>=1是任意没有公因数的奇数!由以上概念就可以导出任意一个本原勾股数组。2、素数计数(素数定理)令π(x)为1到x中素数的个数1 阅读全文
posted @ 2014-02-26 17:09 龙腾四海365 阅读(1035) 评论(0) 推荐(0)
摘要: +-字符串时间限制:1000 ms | 内存限制:65535 KB难度:1描述Shiva得到了两个只有加号和减号的字符串,字串长度相同。Shiva一次可以把一个加号和它相邻的减号交换。他想知道最少需要多少次操作才能把第一个字符串变换成第二个字符串。你现在要去帮助他完成那个这个问题。输入多组测试数据每组数据有两行,每行包含一个由”+”和”-“最成的字符串。每个子符串长度不超过5000。输出仅一个整数,输出最少需要操作的次数。如果答案不存在,输出-1。样例输入++-+--+ -++--++ 样例输出4来源NBOJ上传者TC_周亿 1 #include 2 #include 3 char str.. 阅读全文
posted @ 2014-02-26 15:33 龙腾四海365 阅读(242) 评论(0) 推荐(0)
摘要: 寻找最大数时间限制:1000 ms | 内存限制:65535 KB难度:2描述请在整数 n 中删除m个数字, 使得余下的数字按原次序组成的新数最大,比如当n=92081346718538,m=10时,则新的最大数是9888输入第一行输入一个正整数T,表示有T组测试数据 每组测试数据占一行,每行有两个数n,m(n可能是一个很大的整数,但其位数不超过100位,并且保证数据首位非0,m小于整数n的位数)输出每组测试数据的输出占一行,输出剩余的数字按原次序组成的最大新数样例输入292081346718538 101008908 5样例输出988898来源第六届itat复赛B卷2题改编上传者ACM_赵铭 阅读全文
posted @ 2014-02-26 14:55 龙腾四海365 阅读(191) 评论(0) 推荐(0)
摘要: 阶乘之和时间限制:3000 ms | 内存限制:65535 KB难度:3描述给你一个非负数整数n,判断n是不是一些数(这些数不允许重复使用,且为正数)的阶乘之和,如9=1!+2!+3!,如果是,则输出Yes,否则输出No;输入第一行有一个整数0 2 int s[]={1,2,6,24,120,720,5040,40320,362880}; 3 int main() 4 { 5 int T; 6 scanf("%d",&T); 7 while(T--) 8 { 9 int i,j,n;10 scanf("%d",&n);11 ... 阅读全文
posted @ 2013-12-13 13:50 龙腾四海365 阅读(147) 评论(0) 推荐(0)
摘要: 有趣的数时间限制:3000 ms | 内存限制:65535 KB难度:2描述把分数按下面的办法排成一个数表。1/1 1/2 1/3 1/4.....2/1 2/2 2/3....3/1 3/2 ....4/1..... .........我们以z字型方法给上表的每项编号。特定方法:第一项是1/1,然后是1/2、2/1、3/1、2/2、1/3、1/4、2/3……。编程输入项号N(1int main(){ int T; scanf("%d",&T); while(T--) { int i,s,t; int n; scanf("%d"... 阅读全文
posted @ 2013-12-12 21:51 龙腾四海365 阅读(429) 评论(0) 推荐(0)
摘要: 独木舟上的旅行时间限制:3000 ms | 内存限制:65535 KB难度:2描述进行一次独木舟的旅行活动,独木舟可以在港口租到,并且之间没有区别。一条独木舟最多只能乘坐两个人,且乘客的总重量不能超过独木舟的最大承载量。我们要尽量减少这次活动中的花销,所以要找出可以安置所有旅客的最少的独木舟条数。现在请写一个程序,读入独木舟的最大承载量、旅客数目和每位旅客的重量。根据给出的规则,计算要安置所有旅客必须的最少的独木舟条数,并输出结果。输入第一行输入s,表示测试数据的组数; 每组数据的第一行包括两个整数w,n,80 2 #include 3 int s[330]; 4 int cmp(const. 阅读全文
posted @ 2013-12-12 21:10 龙腾四海365 阅读(162) 评论(0) 推荐(0)
摘要: 月老的烦恼(1)时间限制:1000 ms | 内存限制:65535 KB难度:3描述月老最近遇到了一个很棘手的问题,就是“剩男”“剩女”急速增长,而自己这边又人手不足导致天天都得加班。现在需要你来帮助月老解决这个问题,牵红绳的规则很简单:每个男生都一个编号n(1 2 #define MAX 500001 3 int s[MAX]={0,0}; 4 int main() 5 { 6 int T; 7 int i,j; 8 s[3]=s[5]=s[7]=1; 9 for(j=2;j#define max 500000int a[max+1]={0};int main... 阅读全文
posted @ 2013-12-10 13:22 龙腾四海365 阅读(249) 评论(0) 推荐(0)
摘要: 确定比赛名次Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9179 Accepted Submission(s): 3577 Problem Description有N个比赛队(1 2 #include 3 #define MAX 550 4 int a[MAX][MAX]; 5 int b[MAX],c[MAX]; 6 int m,n; 7 void toposort() 8 { 9 int i,j,k;10 for(... 阅读全文
posted @ 2013-12-08 13:58 龙腾四海365 阅读(152) 评论(0) 推荐(0)
摘要: 星期几?时间限制:500 ms | 内存限制:65535 KB难度:2描述 Acmer 小鱼儿 埋头ku算一道题 条件:已知给定 一日期 告诉你这一天是 星期 n,让你计算在未来的m的p次方的天数后是星期几?他很苦恼,聪明的你能帮助他吗?输入有多组测试数据,每组测试数据以包含三个整数n,m,p(n10)输出输出过了这么多天后是星期几样例输入3 2 205 3 100样例输出72 1 #include 2 3 int f(int a,int b) 4 { 5 long long int t; 6 if(b==0) 7 return 1; 8 if(b==1) ... 阅读全文
posted @ 2013-12-07 20:48 龙腾四海365 阅读(192) 评论(0) 推荐(0)
摘要: The Triangle时间限制:1000 ms | 内存限制:65535 KB难度:4描述7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1) Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the 阅读全文
posted @ 2013-12-07 17:46 龙腾四海365 阅读(143) 评论(0) 推荐(0)
摘要: 对称排序时间限制:1000 ms | 内存限制:65535 KB难度:1描述In your job at Albatross Circus Management (yes, it's run by a bunch of clowns), you have just finished writing a program whose output is a list of names in nondescending order by length (so that each name is at least as long as the one preceding it). Howeve 阅读全文
posted @ 2013-12-05 13:41 龙腾四海365 阅读(188) 评论(0) 推荐(0)
摘要: A problem is easy时间限制:1000 ms | 内存限制:65535 KB难度:3描述When Teddy was a child , he was always thinking about some simple math problems ,such as “What it’s 1 cup of water plus 1 pile of dough ..” , “100 yuan buy 100 pig” .etc..One day Teddy met a old man in his dream , in that dream the man whose name wa 阅读全文
posted @ 2013-12-05 11:30 龙腾四海365 阅读(231) 评论(0) 推荐(0)
摘要: 小明的求助时间限制:2000 ms | 内存限制:65535 KB难度:2描述小明对数学很有兴趣,今天老师出了道作业题,让他求整数N的后M位,他瞬间感觉老师在作弄他,因为这是so easy! 当他看到第二道题目的时候,他就确定老师在捉弄他了,求出N^P的后M位,因为他不会了。你能帮他吗?输入第一行包含一个整数T(T 2 #include 3 int f(int a,long long int n,int m) 4 { 5 long long int t; 6 if(n==0) 7 return 1; 8 if(n==1) 9 return a%m;1... 阅读全文
posted @ 2013-12-04 21:54 龙腾四海365 阅读(140) 评论(0) 推荐(0)
摘要: 快速查找素数时间限制:1000 ms | 内存限制:65535 KB难度:3描述现在给你一个正整数N,要你快速的找出在2.....N这些数里面所有的素数。输入给出一个正整数数N(N 2 #define MAX 2000000 3 int a[MAX+1]={0}; 4 int main() 5 { 6 int i,j,n; 7 for(i=2;i 2 #include 3 #include 4 #include 5 using namespace std; 6 const int M1=2000100,M2=1000000; 7 bool NotPrime[M1]={1,1,0... 阅读全文
posted @ 2013-12-04 21:18 龙腾四海365 阅读(692) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页