上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 20 下一页
摘要: 问题描述小明正在玩一个“翻硬币”的游戏。桌上放着排成一排的若干硬币。我们用 * 表示正面,用 o 表示反面(是小写字母,不是零)。比如,可能情形是:**oo***oooo如果同时翻转左边的两个硬币,则变为:oooo***oooo现在小明的问题是:如果已知了初始状态和要达到的目标状态,每次只能同时翻转相邻的两个硬币,那么对特定的局面,最少要翻动多少次呢?我们约定:把翻动相邻的两个硬币叫做一步操作,那么要求:输入格式两行等长的字符串,分别表示初始状态和要达到的目标状态。每行的长度 2 #include 3 #include 4 #include 5 #include 6 using namespa 阅读全文
posted @ 2014-02-23 20:40 galaxy77 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 问题描述某涉密单位下发了某种票据,并要在年终全部收回。每张票据有唯一的ID号。全年所有票据的ID号是连续的,但ID的开始数码是随机选定的。因为工作人员疏忽,在录入ID号的时候发生了一处错误,造成了某个ID断号,另外一个ID重号。你的任务是通过编程,找出断号的ID和重号的ID。假设断号不可能发生在最大和最小号。输入格式要求程序首先输入一个整数N(N 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 char s[1000002]; 8 bool vis[1000002]; 9 10 int main()11 阅读全文
posted @ 2014-02-23 20:17 galaxy77 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 问题描述小明为某机构设计了一个十字型的徽标(并非红十字会啊),如下所示:..$$$$$$$$$$$$$....$...........$..$$$.$$$$$$$$$.$$$$...$.......$...$$.$$$.$$$$$.$$$.$$.$...$...$...$.$$.$.$$$.$.$$$.$.$$.$.$...$...$.$.$$.$.$.$$$$$.$.$.$$.$.$...$...$.$.$$.$.$$$.$.$$$.$.$$.$...$...$...$.$$.$$$.$$$$$.$$$.$$...$.......$...$$$$.$$$$$$$$$.$$$..$...... 阅读全文
posted @ 2014-02-22 19:16 galaxy77 阅读(406) 评论(0) 推荐(0) 编辑
摘要: 问题描述100 可以表示为带分数的形式:100 = 3 + 69258 / 714。还可以表示为:100 = 82 + 3546 / 197。注意特征:带分数中,数字1~9分别出现且只出现一次(不包含0)。类似这样的带分数,100 有 11 种表示法。输入格式从标准输入读入一个正整数N (N 2 #include 3 #include 4 using namespace std; 5 6 int a[10],vis[10],ans; 7 int const n=9; 8 9 __int64 num,num1,num2,num3;10 11 __int64 solve(int i,int j.. 阅读全文
posted @ 2014-02-22 19:13 galaxy77 阅读(387) 评论(0) 推荐(0) 编辑
摘要: http://lx.lanqiao.org/problem.page?gpid=T24问题描述小张是软件项目经理,他带领3个开发组。工期紧,今天都在加班呢。为鼓舞士气,小张打算给每个组发一袋核桃(据传言能补脑)。他的要求是:1. 各组的核桃数量必须相同2. 各组内必须能平分核桃(当然是不能打碎的)3. 尽量提供满足1,2条件的最小数量(节约闹革命嘛)输入格式输入包含三个正整数a, b, c,表示每个组正在加班的人数,用空格分开(a,b,c#include#include#include#includeusing namespace std;int get(int a,int b){ in... 阅读全文
posted @ 2014-02-20 20:10 galaxy77 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define maxx 100002 7 using namespace std; 8 int a[20022],c[100022],x[100022],n,zuo[100022],you[100022]; 9 10 int lowbit(int x)11 {12 return x&(-x);13 }14 15 __int64 sum(int p)16 {17 __int64 ans=0;18 while(p>0)19 {20 ... 阅读全文
posted @ 2014-02-12 00:57 galaxy77 阅读(290) 评论(0) 推荐(0) 编辑
摘要: poj 阅读全文
posted @ 2014-02-11 23:34 galaxy77 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 【题意】给出n场婚礼的开始时间和结束时间 牧师要在婚礼上待的时间要超过总时间的一半以上且牧师要在整点时刻开始祝福整点时刻结束祝福问牧师是否能给所有新人带去祝福。【思路】: 题目上讲了 牧师待的时间要 超过总时间的一半以上 所以总时间段的中点时段牧师必须在场 算出中点时段 排序 再判断这样的 顺序是否可行就可以了。 如何判断呢 这里要用贪心的思想 一场婚礼的开始时间要尽可能早一边给下面的婚礼腾出更多的时间来,所以一开始要假设 牧师的开始时间就是总时间 的开始时间 要是比上一场的结束时间还早 就改成上场的结束时间 1 #include 2 #incl... 阅读全文
posted @ 2014-02-11 23:33 galaxy77 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 先来个最水的poj 2524Ubiquitous Religionshttp://poj.org/problem?id=2524【题意】:给出n个大学生,其中有m对宗教信仰相同的学生,请你估算这n个学生中最多有多少种宗教信仰。【思路】: 先设 答案为n 每合并一个集合减一就ok了 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 int n; 9 int f[50002];10 11 void init()12 {13 for(int i=0;i 2 #include 3 usi... 阅读全文
posted @ 2014-02-07 11:33 galaxy77 阅读(428) 评论(0) 推荐(0) 编辑
摘要: 中南oj 1335http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1335 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int h[100002],p[100002]; 8 9 int find1(int l,int r,int x)10 {11 int m;12 while(lx)16 r=m;17 else l=m+1;18 }19 return l;2... 阅读全文
posted @ 2014-01-09 21:20 galaxy77 阅读(245) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 20 下一页