上一页 1 ··· 95 96 97 98 99 100 101 102 103 ··· 119 下一页
摘要: /*大致题意:n个城市,先把1号断电,继而每隔m断电使标号为2的最后被限电;转化为(n-1)个城市,最后断电的为标号为1的城市,求最小的m*/ #include<stdio.h>bool is_joseph(int m,int n){ int i,j; int s=0; for(i=2;i<=n;i++) s=(s+m)%i; if((s+1)==1) return 1; return 0;}int main(){ int i,j,k; int m,n,s; while(scanf("%d",&n),n) { ... 阅读全文
posted @ 2012-08-01 10:21 加拿大小哥哥 阅读(295) 评论(0) 推荐(0)
摘要: JosephTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 40823Accepted: 15337DescriptionThe Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n, standing in circle every mth is going to be executed an 阅读全文
posted @ 2012-08-01 09:14 加拿大小哥哥 阅读(230) 评论(0) 推荐(0)
摘要: #include#includeint vis[310];void joseph(int n,int m){ int i,j,k; int cnt=0,count=0; memset(vis,0,sizeof(vis));//0表示未选中 for(i=1;count1)因为实际生活中编号总是从1开始,我们输出f[n]+1 由于是逐级递推,不需要保存每个f[i]*/ #include #includeint main() { int n,m,i,s=0; scanf("%d%d",&n,&m); for(i=2; i#include#inclu... 阅读全文
posted @ 2012-07-31 20:00 加拿大小哥哥 阅读(433) 评论(0) 推荐(0)
摘要: 线性表插入与删除操作Time Limit: 1000 ms Case Time Limit: 1000 ms Memory Limit: 65536 KBSubmit: 78 Accepted: 40 [Prev][Next]Description实现线性表的插入和删除基本操作Input第一行给出线性表内现有数据元素的数目N,1<=N<=10;第二行给出N个整数:a1、a2、a3…aN,整数之间用一个空格隔开,表示线性表现有的数据元素。第三行给出两个整数K、E1,1<=K<=N,表示在第K个元素前插入值为E1的数据元素;第四行给出一个整数E2,表示在线性表中删除第一个值 阅读全文
posted @ 2012-07-30 21:25 加拿大小哥哥 阅读(442) 评论(0) 推荐(0)
摘要: 时间限制:1000ms内存限制:65536kB描述在 skew binary表示中, 第 k 位的值xk表示xk*(2k+1-1)。 每个位上的可能数字是0 或 1,最后面一个非零位可以是2, 例如, 10120(skew) = 1*(25-1) + 0*(24-1) + 1*(23-1) + 2*(22-1) + 0*(21-1) = 31 + 0 + 7 + 6 + 0 = 44. 前十个skew数是 0、1、2、10、11、12、20、100、101、以及102。输入输入包含一行或多行,每行包含一个整数n。 如果 n = 0 表示输入结束,否则n是一个skew 数输出对于每一个输入,输出 阅读全文
posted @ 2012-07-30 18:55 加拿大小哥哥 阅读(297) 评论(0) 推荐(0)
摘要: 时间限制:1000ms内存限制:65536kB描述6*9 = 42 对于十进制来说是错误的,但是对于13进制来说是正确的。即, 6(13) * 9(13) = 42(13), 而 42(13) = 4 * 131 + 2 * 130 = 54(10)。 你的任务是写一段程序读入三个整数p、q和 r,然后确定一个进制 B(2#include#include#includeint vis[35];int vis_temp1[35];int vis_temp2[35];int max;long long My_Pow(int m,int n){ int i; int ans=1; ... 阅读全文
posted @ 2012-07-30 18:41 加拿大小哥哥 阅读(464) 评论(0) 推荐(0)
摘要: //123*20 相当于 100*20 + 20*20+3 //常规方法N>=13就溢出 #include#include#include#define N 10000//因为每位里存储的是小于10000的数,所以缩小4倍 int vis[N];int main(){ int i,j,m; ... 阅读全文
posted @ 2012-07-30 14:58 加拿大小哥哥 阅读(185) 评论(0) 推荐(0)
摘要: Problem DescriptionIgnatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him?Given a positive integers Y which indicate the start year, and a positive integer N, your task is to tell the Nth leap year from year Y.Note:if year Y is a leap year, then 阅读全文
posted @ 2012-07-30 10:11 加拿大小哥哥 阅读(1133) 评论(0) 推荐(0)
摘要: 大致题意:给出自从2000 1 1过的天数,以-1结束,输出日期和星期//以后遇到闰年的问题,坚决用二维数组 #include<stdio.h>#include<string.h>#define N 10010char date[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};int vis[2][12]={31,28,3 阅读全文
posted @ 2012-07-30 09:57 加拿大小哥哥 阅读(277) 评论(0) 推荐(0)
摘要: 字符串替换Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 7290Accepted: 3451Description编写一个C程序实现将字符串中的所有"you"替换成"we"Input输入包含多行数据 每行数据是一个字符串,长度不超过1000 数据以EOF结束Output对于输入的每一行,输出替换后的字符串Sample Inputyou are what you doSample Outputwe are what we do第一:#include<stdio.h> char 阅读全文
posted @ 2012-07-30 08:42 加拿大小哥哥 阅读(757) 评论(0) 推荐(0)
上一页 1 ··· 95 96 97 98 99 100 101 102 103 ··· 119 下一页