摘要: Description有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。Input输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000。Output输出对应也有若干行,每行包含一个数字1或0,如果最后你是胜者,则为1,反之,则为0。Sample Input2 18 44 阅读全文
posted @ 2011-07-11 13:26 又是一年夏天 阅读(938) 评论(0) 推荐(0)
摘要: 要:本文从介绍基础概念入手,探讨了在C/C++中对日期和时间操作所用到的数据结构和函数,并对计时、时间的获取、时间的计算和显示格式等方面进行了阐述。本文还通过大量的实例向你展示了time.h头文件中声明的各种函数和数据结构的详细使用方法。关键字:UTC(世界标准时间),Calendar Time(日历时间),epoch(时间点),clock tick(时钟计时单元)1.概念在C/C++中,对字符串的操作有很多值得注意的问题,同样,C/C++对时间的操作也有许多值得大家注意的地方。最近,在技术群中有很多网友也多次问到过C++语言中对时间的操作、获取和显示等等的问题。下面,在这篇文章中,笔者将主要 阅读全文
posted @ 2011-07-10 14:25 又是一年夏天 阅读(304) 评论(0) 推荐(0)
摘要: 在java中,要是 出现接口中常量和方法冲突时。1.要是常量冲突,可以在实现接口里实用全限定名(接口名称.常量名称明确指定常量所属接口如果是方法冲突,只要实现一个方法就可以了。public class hh{ public static void main(String []args) { Circle circle=new Circle(7); float area=circle.getArea(); System.out.println("圆的面积:"+area); float girth=circle.getGirth(); System.out.println(&q 阅读全文
posted @ 2011-07-09 19:34 又是一年夏天 阅读(287) 评论(0) 推荐(0)
摘要: class Animal{ public static void textClassMethod() { System.out.println("Animal中的类方法"); } public void textinstanceMethod() { System.out.println("Animal中的实例方法"); }} class Cat extends Animal { public static void textClassMethod() { System.out.println("Cat中的类方法"); } public 阅读全文
posted @ 2011-07-09 16:11 又是一年夏天 阅读(623) 评论(0) 推荐(1)
摘要: /*java.lang包中的Math类提供有常量 * 并包含有用于执行基本数学运算的 * 方法,如初等指数、对数、平方根 * 用于进行更高级的数学运算。由于 * 在Math类的方法都是静态的,因此可 * 直接通过类来调用 * Math.cos(angle); * (使用静态导入(static import)的语言特性"import static java.lang.Math.*" * 就不必在每一个数学函数前面都写Math了。这允许通过简单的 * 名称调用Math类中的方法,例如:“cos(sngle)”! * */public class hello { public s 阅读全文
posted @ 2011-07-08 20:51 又是一年夏天 阅读(708) 评论(0) 推荐(0)
摘要: import java.text.*;public class hello { //自定义方法,根据参数传入的匹配模式,来格式化数字 public static void cuntomFormat(String pattern,double value) { DecimalFormat myFormatter=new DecimalFormat(pattern); //创建模式对象 String output=myFormatter.format(value); System.out.println(value+" "+pattern+" "+outpu 阅读全文
posted @ 2011-07-08 20:11 又是一年夏天 阅读(318) 评论(0) 推荐(0)
摘要: import java.util.Calendar;import java.util.Locale;public class hello { public static void main(String[] args) { long n= 382112; System.out.format("%d%n",n); System.out.format("%08d%n", n); System.out.format("%+8d%n", n); System.out.format("%,8d%n", n); System. 阅读全文
posted @ 2011-07-08 19:50 又是一年夏天 阅读(357) 评论(0) 推荐(0)
摘要: 记录下来,以后找方便点#include<stdio.h>#include<stdlib.h>#include<time.h>#define N 100void QKSort(int r[],int low,int high)/*对记录数组r[low..high]用快速排序算法进行排序*/{ int pos; if(low<high) { pos=QKPass(r,low,high); QKSort(r,low,pos-1);//对左部子表进行排序 QKSort(r,pos+1,high);//对右部子表进行排序 }}//一趟快速排序算法int QKPa 阅读全文
posted @ 2011-07-08 19:08 又是一年夏天 阅读(197) 评论(0) 推荐(0)
摘要: Problem Description不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前.死亡骑士:"我要买道具!"地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个."死亡骑士:"好的,给我一个血瓶."说完他掏出那张N元的大钞递给地精商人.地精商人:"我忘了提醒你了,我们这里没有找客人钱的习惯的,多的钱我们都当小费收了的,嘿嘿."死亡骑士:"......" 阅读全文
posted @ 2011-07-07 22:38 又是一年夏天 阅读(305) 评论(0) 推荐(0)
摘要: #include<stdio.h>#include<stdlib.h>#include<time.h>#define N 300void InSort(int a[],int length){ int i,j; for(i=2;i<=length;i++) { a[0]=a[i];j=i-1;while(a[0]<a[j]){ a[j+1]=a[j];j--;}a[j+1]=a[0]; }}void main(){ int i;int a[N+1];a[0]=0;srand((unsigned)time(NULL));for(i=1;i<= 阅读全文
posted @ 2011-07-07 12:29 又是一年夏天 阅读(112) 评论(0) 推荐(0)