博文

【愚蠢的摄影师】(2008-08-12 20:29:00)

摘要:  Time Limit:1000MS  Memory Limit:16384KTotal Submit:29 Accepted:13 Description 背景 "如果两个人相差一秒出生, 其中一个是小孩, 那么另一个也是小孩. 由此可以推论, 所有人均是小孩." 问题 数计系是一个由N个人组成的大家庭, 分别为1, 2, 3, ..., N岁. 有一次系主任想为全系拍张合照. 需要所有学生站成一排. 起先他想按他们的岁数从小到大安排, 但后来又觉得这样不自然. 于是他建议按如下方案站排: 1岁的在最左边. 每相邻两人不得相差超过2岁. 这样学生的岁数看起来显得很平均(25岁和27岁的人差别很难看出). 存在多种方案满足此要求. 摄影师不想违反系主任的意愿, 就为每种可能的安排分别拍了一张照片. Input 整数N, 1<=N<=55. Output 所拍照片张数. Sample Input 4 Sample Output 4 Hint 若N=4, 则有4种可能的安排: (1,2,3,4), (1,2,4,3), (1,3,2,4) and (1,3,4,2). Source Open collegiate programming contest for high school children of the Sverdlovsk region, October 11, 2  #include<stdio.h> int main() { int i,n; int tog,tog_1,tog_2,tog_12_1,temp; long f[58]; tog=1; tog_1=1; tog_2=0; tog_12_1=1; f[1]=1; f[2]=1; for(i=3;i<=55;i++) { f[i]=tog+tog_1+tog_2; temp=tog_12_1; tog_12_1=tog_1; tog=f[i]-tog_2; tog_1=tog_1+tog_2; tog_2=temp; } scanf("%d",&n); printf("%......

阅读全文(1896) | 评论:0

【2007年普及组3】守望者的逃离(2008-08-12 20:28:00)

摘要: Time Limit:10000MS  Memory Limit:65536KTotal Submit:41 Accepted:3 Case Time Limit:1000MS Description 【问题描述】 恶魔猎手尤迫安野心勃勃.他背叛了暗夜精灵,率深藏在海底的那加企图叛变:守望者在与尤迪安的交锋中遭遇了围杀.被困在一个荒芜的大岛上。为了杀死守望者,尤迪安开始对这个荒岛施咒,这座岛很快就会沉下去,到那时,刀上的所有人都会遇难:守望者的跑步速度,为17m/s, 以这样的速度是无法逃离荒岛的。庆幸的是守望者拥有闪烁法术,可在1s内移动60m,不过每次使用闪烁法术都会消耗魔法值10点。守望者的魔法值恢复的速度为4点/s,只有处在原地休息状态时才能恢复。 现在已知守望者的魔法初值M,他所在的初始位置与岛的出口之间的距离S,岛沉没的时间T。你的任务是写一个程序帮助守望者计算如何在最短的时间内逃离荒岛,若不能逃出,则输出守望者在剩下的时间内能走的最远距离。注意:守望者跑步、闪烁或休息活动均以秒(s)为单位。且每次活动的持续时间为整数秒。距离的单位为米(m)。 Input 输入仅一行,包括空格隔开的三个非负整数M,S,T。Output 输出包含两行: 第1行为字符串"Yes"或"No" (区分大小写),即守望者是否能逃离荒岛。 第2行包含一个整数,第一行为"Yes" (区分大小写)时表示守望着逃离荒岛的最短时间 第一行为"No" (区分大小写) 时表示守望者能走的最远距离。 Sample Input 39 200 4Sample Output No 197 Hint 输入 36 255 10 输出 Yes 6 【限制】 30%的数据满足: 1 <= T<= 10, 1 <=S<= 100 50%的数据满足: 1 <= T <= 1000, 1 <= S <= 10000 100%的数据满足: 1 <= T <= 300000, 0 <= M<=1000 1 <=S <= 10^8 Source xinyue#include<stdio.h> __int64 f[300005][2]; int main() { __int64 i,min,M......

阅读全文(1425) | 评论:0

【四川选拔】文本的输入(2008-08-12 20:26:00)

摘要: Time Limit:10000MS  Memory Limit:65536KTotal Submit:25 Accepted:6 Case Time Limit:1000MS Description   人们在输入文本时,除了逐个输入这种方式外,还可以利用剪贴板进行复制,如果打入一个字母需要1的时间,将已输入的部分复制进剪贴板需要5的时间(Ctrl+A,Ctrl+C,还有一个键取消全选状态),将剪贴板的内容粘贴出来需要2的时间(Ctrl+V)。   如果我们不关心输入文本的内容,而只关心输入文本的长度,要输入一个长度不低于N的文本最少需要多少时间? Input   一个正整数N(0<=N<=200),表示文本的长度。Output   一个正整数K,表示需要的最短的时间。Sample Input   6Sample Output   6Source xinyue #include<stdio.h> #include<math.h> int f(int n) { int a,min=n,minn,i; if( n <= 14 ) return n; else { minn=f(n-1)+1; if( minn < min ) min=minn; for( i=2; i <= sqrt(n); i++ ) { if( n%i == 0 ) a=n/i; else a=n/i+1; minn=f(a)+5+(i-1)*2; if( minn < min ) min=minn; } return min; } } int main() { int n; scanf("%d",&n); printf("%d\n",f(n)); return 0; }......

阅读全文(1795) | 评论:0

Order Count(HD1223)(2008-08-12 20:17:00)

摘要: 好开心,又搞定一个动规题Order CountProblem Description If we connect 3 numbers with "<" and "=", there are 13 cases: 1) A=B=C 2) A=B<C 3) A<B=C 4) A<B<C 5) A<C<B 6) A=C<B 7) B<A=C 8) B<A<C 9) B<C<A 10) B=C<A 11) C<A=B 12) C<A<B 13) C<B<A If we connect n numbers with "<" and "=", how many cases then? Input The input starts with a positive integer P(0<P<1000) which indicates the number of test cases. Then on the following P lines, each line consists of a positive integer n(1<=n<=50) which indicates the amount of numbers to be connected. Output For each input n, you should output the amount of cases in a single line. Sample Input 213 Sample Output 113Hint Hint Huge input, scanf is recommended. Author weigang Lee MY CODE #include<stdio.h> void mix(int a[],int b[],int c)//大整数乘法 { int i=0,cout=0; while(b[i]!=-1) {   a[i]=b[i]*c+cout;   cout=0;   if(a[i]>=10)   {  &......

阅读全文(2331) | 评论:2