取石子游戏
Time Limit:1000MS Memory Limit:10000K
有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。
Input
输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000。
Output
输出对应也有若干行,每行包含一个数字1或0,如果最后你是胜者,则为1,反之,则为0。
Sample Input
2 1
8 4
4 7
Sample Output
0
1
0
----------------解决方案--------------------------------------------------------
你太坏了,拿这个题目来吓人
这期我没有发言权
做为iwfy的好朋友,同时也让更多的人,尤其是那些觉得自己水平不够好的朋友能参与到讨论中来我替iwfy发一个中等一点的题目.(来自柏林大学的一道考试题)
1、第一个答案是b的问题是哪一个?
(a)2;(b) 3;(c)4;(d)5;(e)6
2、唯一的连续两个具有相同答案的问题是:
(a)2,3;(b)3,4;(c)4,5;(d)5,6;(e)6,7;
3、本问题答案和哪一个问题的答案相同?
(a)1;(b)2;(c)4;(d)7;(e)6
4、答案是a的问题的个数是:
(a)0;(b)1;(c)2;(d)3;(e)4
5、本问题答案和哪一个问题的答案相同?
(a)10;(b)9;(c)8;(d)7;(e)6
6、答案是a的问题的个数和答案是什么的问题的个数相同?
(a)b;(b)c;(c)d;(d)e;(e)以上都不是
7、按照字母顺序,本问题的答案和下一个问题的答案相差几个字母?
(a)4;(b)3;(c)2;(d)1;(e)0。(注:a和b相差一个字母)
8、答案是元音字母的问题的个数是:
(a)2;(b)3;(c)4;(d)5;(e)6。(注:a和e是元音字母)
9、答案是辅音字母的问题的个数是:
(a)一个质数;(b)一个阶乘数;(c)一个平方数;(d)一个立方数,(e)5的倍数
10、本问题的答案是:
(a)a;(b)b;(c)c;(d)d;(e)e。
求这10个题目的答案.
不限定你要用计算机.如果你能人工推出来那你是真正的高手中的高手
[此贴子已经被作者于2007-4-6 12:41:39编辑过]
----------------解决方案--------------------------------------------------------
Contest Problem A : The multiplication of multinomial
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 0 Accepted: 0
Description
Bob a pupil who is very studious . He is only seven years old, but he have studied multinomail all by himself.Today he is studying the multiplication of multionomial. He is so clever that he can calculate the answer quickly.But he don't know whehter the answer is right. So he need your help!
Input
The input contain multiply test case.First line is a integer number which is the number of test case, ans then two lines is following.Each line describe a multiomial. The first number of each is the length of the multinomial, and then is the coefficients of the multinomial. For example we can a multinomial (1 + x + x^2 + x^3)describe like this 4 1 1 1 1.
Output
For each case please output the cofficients of the answer.The coefficient which is equal to 0 isn't been output.If all cofficients is 0, output 0 please.Please output a blank between each cofficients.
Sample Input
2
3 1 1 1
3 2 3 4
3 -1 -1 -1
3 2 3 4
Sample Output
2 5 9 7 4
-2 -5 -9 -7 -4
Contest Problem B : A Easy Work
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 0 Accepted: 0
Description
Give a integer n, please find the permutation from 1~n.
Input
Each line of input contains a integer n which described above.
Output
For input print the permutation of 1~n with the lexicographically smallest.
Print a blank after each case.
Sample Input
3
4
Sample Output
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1
Contest Problem C : Just need 8
Time Limit: 5000 MS Memory Limit: 65536 K
Total Submit: 0 Accepted: 0
Description
Many people like the number '8'.Do you love the number ‘8’? Many people make it their lucky number.And now many people think that the number which is the multiple of eight is also lucky too. Now give you a number N, could find the smallst N numbers which is the multiple of eight or the last digit is eight.
Input
Each line of inout contain a integer N described above.
Output
For each inout output N (0 < N <= 1000000)numbers described above.
Sample Input
3
Sample Output
8
16
18
Contest Problem D : Help me please!
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 0 Accepted: 0
Description
My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece of one pie, not several small pieces since that looks messy. This piece can be one whole pie though.
My friends are very annoying and if one of them gets a bigger piece than the others, they start complaining. Therefore all of them should get equally sized (but not necessarily equally shaped) pieces, even if this leads to some pie getting spoiled (which is better than spoiling the party). Of course, I want a piece of pie for myself too, and that piece should also be of the same size.
What is the largest possible piece size all of us can get? All the pies are cylindrical in shape and they all have the same height 1, but the radii of the pies can be different.
Input
One line with a positive integer: the number of test cases. Then for each test case:
One line with two integers N and F with 1 ≤ N, F ≤ 10 000: the number of pies and the number of friends.
One line with N integers ri with 1 ≤ ri ≤ 10 000: the radii of the pies.
Output
For each test case, output one line with the largest possible volume V such that me and my friends can all get a pie piece of size V. The answer should be given as a floating point number with four digits after the point.
Sample Input
3
3 3
4 3 3
1 24
5
10 5
1 4 2 3 4 5 6 5 4 2
Sample Output
25.1327
3.1416
50.2655
Contest Problem E : Barraucda's easy problem
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 0 Accepted: 0
Description
This is a easy problem Barraucda, but it's hard to fwish. help fwish, please ! 一个n*n棋盘上刻着一些数 ,现在从 左上角 出发前往 右下角,从出发点开始累加经过路线上每个点上的数,每条路径上不能有重复的点,求能到达 右下角,累加的最小的值。
Input
有多组数据, n = 0 代表文件结束。 每组数据第一行一个 n, 2 <= n <= 5 下面是 一个n*n 的棋盘, 棋盘上每个数 在 -1000 到 1000 之间 。
Output
每组数据包含一行, 输出最小值。
Sample Input
2
1 1
1 1
0
Sample Output
2
Contest Problem F : fwish's easy problem
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 0 Accepted: 0
Description
This is a easy problem Barraucda, but it's hard to fwish. help fwish, please ! 一个n*n棋盘上刻着一些数 ,现在从 左上角 出发前往 右下角,从出发点开始累加经过路线上每个点上的数,每条路径上不能有重复的点,求能到达 右下角,累加的最小的值。
Input
有多组数据, n = 0 代表文件结束。
每组数据第一行一个 n, 2 <= n <= 5
下面是 一个n*n 的棋盘, 棋盘上每个数 在 -1000 到 1000 之间 。
Output
每组数据包含一行, 输出最小值。
Sample Input
2
1 1
1 1
0
Sample Output
2
我全都帖出来了,随便做
[此贴子已经被作者于2007-4-22 22:23:53编辑过]
----------------解决方案--------------------------------------------------------
排列那个题目
给我提交
#include<stdio.h>
int n,a[100],b[100];
void fun(int k)
{
int i;
if(k==n+1)
{
for(i=1;i<n;i++)
printf("%d ",a[i]);
printf("%d\n",a[n]);
}
else
{
for(i=1;i<=n;i++)
{
if(!b[i])
continue;
else
{
b[i]=0;
a[k]=i;
fun(k+1);
b[i]=1;
}
}
}
}
void main()
{
int i;
scanf("%d",&n);
for(i=1;i<=n;i++)a[i]=b[i]=1;
fun(1);
while(scanf("%d",&n)!=EOF)
{
printf("\n");
for(i=1;i<=n;i++)a[i]=b[i]=1;
fun(1);
}
}
二项式:
#include<stdio.h>
void main()
{
int a[1000],b[1000],c[2000],i,j,n,k,l;
scanf("%d",&n);
while(n--)
{
for(i=0;i<2000;i++)c[i]=0;
scanf("%d",&k);
for(i=0;i<k;i++)
scanf("%d",&a[i]);
scanf("%d",&l);
for(i=0;i<l;i++)
scanf("%d",&b[i]);
for(i=0;i<k;i++)
{
for(j=0;j<l;j++)
c[i+j]+=a[i]*b[j];
}
for(i=0;i<(k-1)*(l-1);i++)
if(c[i])
printf("%d ",c[i]);
printf("%d\n",c[i]);
}
}
this fwish easy problem 似乎很 hard
分蛋糕我有点思路了.后面那个我觉得可以用第归因为题目n小于5
周四我要考电路分析.不能在玩编程.PC不要太早把答案贴出来让我和风雨都想想
[此贴子已经被作者于2007-4-23 14:04:47编辑过]
----------------解决方案--------------------------------------------------------
整数排列
#include "stdio.h"
int k[10],j=0,sz[10]={0},i,s[10]={1,2,3,4,5,6,7,8,9,10},cx[10],l,x=0;
void fn(int);
int main()
{
int xh;
while(scanf("%d",&k[j++])!=EOF)
{
j--;
l=0;
x=0;
fn(k[j]);
for(xh=0;xh<10;xh++)sz[xh]=0;
printf("\n");
}
return 0;
}
void fn(int n)
{
int xh1,xh2,b=0;
while(sz[b]==1 && b<k[i])b++;
if(n==1 && l==k[i]-1)
{
cx[l]=b;
if(x!=0)
{
printf("\n");
}
else x=1;
for(xh1=0;xh1<k[i];xh1++)printf("%d ",s[cx[xh1]]);
return ;
}
while(b<k[i])
{
sz[b]=1;
cx[l]=b;
l++;
fn(n-1);
l--;
sz[b]=0;
b++;
while(sz[b]==1 && b<k[i])b++;
}
}
[此贴子已经被作者于2007-4-22 23:06:22编辑过]
----------------解决方案--------------------------------------------------------
什么时候又帖一个题目出来的,说都不说一声
----------------解决方案--------------------------------------------------------
论坛惯例,一期是两题目
----------------解决方案--------------------------------------------------------
今天星期六,大家费点时间想想,这两题其实没有多难
----------------解决方案--------------------------------------------------------
我顶
第一题,从1:2开始考虑,如果我碰到了,那我怎么取也取不完,所以输,但是要是1:3,那我把3取1个出来成1:2,对方就没办法一次取完,那我就赢了,如果碰到2:3,那我把3取2个出来成2:1(不就是刚才的1:2吗)我赢
接下来大家讨论吧
----------------解决方案--------------------------------------------------------
没人做我就做了 传说中的黄金分割
# include <math.h>
# include <stdio.h>
main()
{
long i,j,swap,k;
int mark;
while(scanf("%ld%ld",&i,&j)==2)
{
if(i == j) {printf("1\n");continue;}
if(i>j)
{
swap = j;
j = i;
i = swap;
}
k = j - i;
mark =(int) (k*(1.0+sqrt(5))/2.0 );
if(i==mark)printf("0\n");
else printf("1\n");
}
return 0;
}
有奖金??
----------------解决方案--------------------------------------------------------