Icyblade's profile临风阁BlogListsGuestbookMore Tools Help

临风阁

Icyblade Personal Spaces

Icyblade Wise

Yanni Tribute 紫禁城
by 
by 
by 
by 
by 
by 
by 
by 
by 
by 
More...
November 14

我的 VIM 配置文件( _vimrc )

  1. set ai
  2. set autochdir
  3. set autoindent
  4. set awa
  5. set cindent
  6. set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
  7. set expandtab
  8. set fileencodings=ucs-bom,utf8,GB18030,Big5,latin1
  9. set history=50
  10. set hlsearch
  11. set ignorecase
  12. set incsearch
  13. set laststatus=2
  14. set nobackup
  15. set nocompatible
  16. set number
  17. set paste
  18. set ruler
  19. set shiftwidth=4
  20. set showcmd
  21. set showmatch
  22. set smartcase
  23. set smartindent
  24. set softtabstop=4
  25. set statusline=%F%m%r,\ %Y,\ %{&fileformat}\ \ \ ASCII=\%b,HEX=\0x\%B\ \ \ %l,%c%V\ \ %p%%
  26. set tabstop=4

  27. :map <F5> :tabprevious<CR>
  28. :map <F6> :tabnew<CR>
  29. :map <F7> :tabnext<CR>
  30. :map <F2> :!g++ % -o %<<CR>
  31. :map <F3> :!%<<CR>
  32. :map <F4> :!clear<CR>
  33. :imap <F5> <ESC>:tabprevious<CR>i
  34. :imap <F6> <ESC>:tabnew<CR>i
  35. :imap <F7> <ESC>:tabnext<CR>i
  36. :imap <F2> <ESC>:!g++ % -o %<<CR>
  37. :imap <F3> <ESC>:!%<<CR>
  38. :imap <F4> <ESC>:!clear<CR>

  39. runtime! debian.vim
  40. syntax enable
  41. if filereadable("/etc/vim/vimrc.local")
  42.   source /etc/vim/vimrc.local
  43. endif

  44. if &term=="xterm"
  45. set t_Co=8
  46. set t_Sb=^[[4%dm
  47. set t_Sf=^[[3%dm
  48. endif
November 07

ACM 2009 华中科技大学预选赛

A:A Very Easy Problem!

Description

In A speech contest, when a contestant finishes his speech, the judges will then grade his performance. The staffs remove the highest grade and the lowest grade and compute the average of the rest as the contestant’s final grade. This is an easy problem because usually there are only several judges.

Let’s consider a generalized form of the problem above. Given n positive integers, remove the greatest n1 ones and the least n2 ones, and compute the average of the rest.

Input

The input consists of several test cases. Each test case consists two lines. The first line contains three integers n and n1, n2 (1<=n1, n2<=10,n1+n2<n<=5000) separate by a single space. The second line contains n non-descending positive integers ai (1<=a1<=a2…<=an-1<=an<=10^3 for all i s.t. 1<=i<=n) separated by a single space. The last test case is followed by three zeroes.

Output

For each test case, output the average rounded to six digits after decimal point in a separate line.

Sample Input

5 1 2

1 2 3 4 5

10 4 2

155 220 485 531 582 652 843 902 926 999

0 0 0

Sample Output

3.500000

562.500000

Hint

You can use printf(“%.6lf”,ans) in c/c++ or writeln(ans:0:6) in pascal to output the answer.

B:Yeehaa!

Description

Background
George B. wants to be more than just a good American. He wants to make his daddy proud and become a western hero. You know, like John Wayne.
But sneaky as he is, he wants a special revolver that will allow him to shoot more often than just the usual six times. This way he can fool and kill the enemy easily (at least that's what he thinks).
Problem
George has kidnapped ... uh, I mean ... "invited" you and will only let you go if you help him with the math. The piece of the revolver that contains the bullets looks like this (examples for 6 and 17 bullets):

2

There is a large circle with radius R and n little circles with radius r that are placed inside on the border of the large circle. George wants his bullets to be as large as possible, so there should be no space between the circles. George will decide how large the whole revolver will be and how many bullets it shall contain.Your job is, given R and n, to compute r.

Input

The first line contains the number of scenarios. For each scenario follows a line containing a real number R and an integer n, with 1 <= R <= 100 and 2 <= n <= 100.

Output

The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Then print the value for r, rounded to three decimal places. Terminate the output for the scenario with a blank line.

Sample Input

4

4.0 6

4.0 17

3.14159 100

42 2

Sample Output

Scenario #1:

1.333

Scenario #2:

0.621

Scenario #3:

0.096

Scenario #4:

21.000

C:An Easy Problem!

Description

Have you heard the fact "The base of every normal number system is 10" ? Of course, I am not talking about number systems like Stern Brockot Number System. This problem has nothing to do with this fact but may have some similarity.
You will be given an N based integer number R and you are given the guaranty that R is divisible by (N-1). You will have to print the smallest possible value for N. The range for N is 2 <= N <= 62 and the digit symbols for 62 based number is (0..9 and A..Z and a..z). Similarly, the digit symbols for 61 based number system is (0..9 and A..Z and a..y) and so on.

Input

Each line in the input will contain an integer (as defined in mathematics) number of any integer base (2..62). You will have to determine what is the smallest possible base of that number for the given conditions. No invalid number will be given as input. There are at most 10000 characters in a single line.

Output

If number with such condition is not possible output the line "such number is impossible!" For each line of input there will be only a single line of output. The output will always be in decimal number system.

Sample Input

3

5

A

Sample Output

4

6

11

D:Bad Cowtractors

Description

Bessie has been hired to build a cheap internet network among Farmer John's N (2 <= N <= 1,000) barns that are conveniently numbered 1..N. FJ has already done some surveying, and found M (1 <= M <= 20,000) possible connection routes between pairs of barns. Each possible connection route has an associated cost C (1 <= C <= 100,000). Farmer John wants to spend the least amount on connecting the network; he doesn't even want to pay Bessie.
Realizing Farmer John will not pay her, Bessie decides to do the worst job possible. She must decide on a set of connections to install so that (i) the total cost of these connections is as large as possible, (ii) all the barns are connected together (so that it is possible to reach any barn from any other barn via a path of installed connections), and (iii) so that there are no cycles among the connections (which Farmer John would easily be able to detect). Conditions (ii) and (iii) ensure that the final set of connections will look like a "tree".

Input

The input contains several test cases.

The first line of each case is two space-separated integers:N and M.

Lines 2..M+1: Each line contains three space-separated integers A, B, and C that describe a connection route between barns A and B of cost C.

The end of input is indicated by a line containing n=0 and m=0.

Output

For each case a single integer, containing the price of the most expensive tree connecting all the barns. If it is not possible to connect all the barns, output -1.

Sample Input

5 8

1 2 3

1 3 7

2 3 10

2 4 4

2 5 8

3 4 6

3 5 2

4 5 17

Sample Output

42

Hint

OUTPUT DETAILS:
The most expensive tree has cost 17 + 8 + 10 + 7 = 42. It uses the following connections: 4 to 5, 2 to 5, 2 to 3, and 1 to 3.

E:How many Fibs?

Description

Recall the definition of the Fibonacci numbers:

f1 := 1

f2 := 2

fn := fn-1 + fn-2 (n>=3)

Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a,b].

Input

The input contains several test cases. Each test case consists of two non-negative integer numbers a and b. Input is terminated by a=b=0. Otherwise, a<=b<=10100. The numbers a and b are given with no superfluous leading zeros.

Output

For each test case output on a single line the number of Fibonacci numbers fi with a<=fi<=b.

Sample Input

10 100

1234567890 9876543210

0 0

Sample Output

5

4

F:Lake Counting

Description

Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W') or dry land ('.'). Farmer John would like to figure out how many ponds have formed in his field. A pond is a connected set of squares with water in them, where a square is considered adjacent to all eight of its neighbors.

Given a diagram of Farmer John's field, determine how many ponds he has.

Input

The input consists of several test cases.

The first line of each case :Two space-separated integers: N and M

The second line to N+1th of each case : M characters per line representing one row of Farmer John's field. Each character is either 'W' or '.'. The characters do not have spaces between them.

A line containing 0 0 follows the last case.(don’t process)

Output

For each case output a line contains the number of ponds.

Sample Input

1

Sample Output

2

3

G:Cow BowlingTime

Description

The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this:

7

3 8

8 1 0

2 7 4 4

4 5 2 6 5

Then the other cows traverse the triangle starting from its tip and moving "down" to one of the two diagonally adjacent cows until the "bottom" row is reached. The cow's score is the sum of the numbers of the cows visited along the way. The cow with the highest score wins that frame.

Given a triangle with N (1 <= N <= 350) rows, determine the highest possible sum achievable.

Input

The input consists of several test cases.

The first line of each case : A single integer, N

The second line to N+1th of each case: line i+1 contains i space-separated integers that represent row i of the triangle.

A line containing 0 follows the last case.(don’t process)

Output

For each case output a line contains the largest sum achievable using the traversal rules

Sample Input

5

7

3 8

8 1 0

2 7 4 4

4 5 2 6 5

0

Sample Output

30

Hint

Explanation of the sample:

7

3 8

8 1 0

2 7 4 4

4 5 2 6 5

The highest score is achievable by traversing the cows as shown above.

H:Laser in Cuboids

Description

As we know ,a cuboid(rectangular solid) has three mutually perpendicular edges: a,b,c. when a,b and c are all integer ,the cuboid can be regarded as a*b*c small cubes gluing together; each of the small cube is 1*1*1

3

Now, as in the above figure ,there is a laser beam from one vertex to its diagonal opposite vertex ,the width of the laser is negligible,but we care about how many small cubes the lasser passes through.

Given the integer length of the three edges of the cubooid ,your job ifs to work out how many small cubes laser passes through (not just contact with its edges or vertices)

Input

Each line of the input is a test case ,which contains three integer a,b and c ,0<a,b,c<1000000,the last line of input is “0 0 0”,

Output

For each case ,output the number of small cubes of small cubes the laser passing through

Sample Input

1 1 3

2 2 3

3 3 3

0 0 0

Sample Output

3

4

3

I: Currency Exchange

Description

Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the same pair of currencies. Each point has its own exchange rates, exchange rate of A to B is the quantity of B you get for 1A. Also each exchange point has some commission, the sum you have to pay for your exchange operation. Commission is always collected in source currency.
For example, if you want to exchange 100 US Dollars into Russian Rubles at the exchange point, where the exchange rate is 29.75, and the commission is 0.39 you will get (100 - 0.39) * 29.75 = 2963.3975RUR.
You surely know that there are N different currencies you can deal with in our city. Let us assign unique integer number from 1 to N to each currency. Then each exchange point can be described with 6 numbers: integer A and B - numbers of currencies it exchanges, and real RAB, CAB, RBA and CBA - exchange rates and commissions when exchanging A to B and B to A respectively.
Nick has some money in currency S and wonders if he can somehow, after some exchange operations, increase his capital. Of course, he wants to have his money in currency S in the end. Help him to answer this difficult question. Nick must always have non-negative sum of money while making his operations. 

Input

The first line of the input is the number of test cases. The first line of each test case contains four numbers: N - the number of currencies, M - the number of exchange points, S - the number of currency Nick has and V - the quantity of currency units he has. The following M lines contain 6 numbers each - the description of the corresponding exchange point - in specified above order. Numbers are separated by one or more spaces. 1<=S<=N<=100, 1<=M<=100, V is real number, 0<=V<=103.
For each point exchange rates and commissions are real, given with at most two digits after the decimal point, 10-2<=rate<=102, 0<=commission<=102.
Let us call some sequence of the exchange operations simple if no exchange point is used more than once in this sequence. You may assume that ratio of the numeric values of the sums at the end and at the beginning of any simple sequence of the exchange operations will be less than 104

Output

If Nick can increase his wealth, output YES, in other case output NO to the output file.

Sample Input

1

3 2 1 20.0

1 2 1.00 1.00 1.00 1.00

2 3 1.10 1.00 1.10 1.00

Sample Output

YES

November 04

USACO Section 1.1 Your Ride Is Here 题解 (C)

首先给出原题以及 NOCOW 的翻译: 

Your Ride Is Here

It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let the groups know ahead of time which will be picked up for each comet by a clever scheme: they pick a name for the comet which, along with the name of the group, can be used to determine if it is a particular group's turn to go (who do you think names the comets?). The details of the matching scheme are given below; your job is to write a program which takes the names of a group and a comet and then determines whether the group should go with the UFO behind that comet.

Both the name of the group and the name of the comet are converted into a number in the following manner: the final number is just the product of all the letters in the name, where "A" is 1 and "Z" is 26. For instance, the group "USACO" would be 21 * 19 * 1 * 3 * 15 = 17955. If the group's number mod 47 is the same as the comet's number mod 47, then you need to tell the group to get ready! (Remember that "a mod b" is the remainder left over after dividing a by b; 34 mod 10 is 4.)

Write a program which reads in the name of the comet and the name of the group and figures out whether according to the above scheme the names are a match, printing "GO" if they match and "STAY" if not. The names of the groups and the comets will be a string of capital letters with no spaces or punctuation, up to 6 characters long.

Examples:

InputOutput
COMETQ
HVNGAT
GO
ABSTAR
USACO 
STAY

PROGRAM NAME: ride

This means that you fill in your header with:
PROG: ride


INPUT FORMAT

Line 1:An upper case character string of length 1..6 that is the name of the comet.
Line 2:An upper case character string of length 1..6 that is the name of the group.

NOTE: The input file has a newline at the end of each line but does not have a "return". Sometimes, programmers code for the Windows paradigm of "return" followed by "newline"; don't do that! Use simple input routines like "readln" (for Pascal) and, for C/C++, "fscanf" and "fid>>string".


SAMPLE INPUT (file ride.in)

COMETQ
HVNGAT

OUTPUT FORMAT

A single line containing either the word "GO" or the word "STAY".


SAMPLE OUTPUT (file ride.out)

GO

NOCOW 的翻译在 http://www.nocow.cn/index.php/Translate:USACO/ride


本题是个弱智题,只给出代码和一部分的解释:


/*

PROB:ride

LANG:C

*/


#include <stdio.h>

#include <string.h>


int main(void) {

    /* 读入 in 文件内容 */

    FILE *inp = fopen("ride.in","r");

    if (inp == ((void *)0)) {

       printf("Error opening ride.in!\n");

       getch();

       return 1;

    }

    char ln1[7],ln2[7];

    fscanf(inp,"%s",ln1);

    fscanf(inp,"%s",ln2);

    fclose(inp);

    //printf("ln1: %s\nln2: %s\n",ln1,ln2);//

    

    /* 分析 in 文件内容 */

    int len1,len2;

    len1 = strlen(ln1);

    len2 = strlen(ln2);

    //printf("len1: %d\nlen2: %d\n",len1,len2);//

    

    /* 计算 */

    int i,j;

    int sum1 = 1;

    int sum2 = 1;

    for (i = 0;i <= len1 - 1;i++) {

        sum1 *= (ln1[i] - 64);

    }

    for (j = 0;j <= len2 - 1;j++) {

        sum2 *= (ln2[j] - 64);

    }

    //printf("sum1: %d\nsum2: %d\n",sum1,sum2);//

    

    /* 生成结果 */ 

    char result[5];

    if ((sum1 % 47) == (sum2 % 47))

       strcpy(result,"GO");

    else

        strcpy(result,"STAY");

    //printf("%s\n",result);//

    

    /* 输出到 out */

    FILE *outp = fopen("ride.out","w");

    if (outp == ((void *)0)) {

       printf("Error writeing ride.out!\n");

       getch();

       return 2;

    }

    fprintf(outp,"%s\n",result);

    fclose(outp);


    /* 结束程序 */

    //getch();//

    return 0;

}


说几句:

1) 我的开发环境是 WinXP SP3, Dev-C++ 4.9.9.2 配合 VIM+GCC+GDB 的经典组合。

2) /* */ 部分是注释, // 部分是调试代码(Dev-C++ 不好调,众所周知,所以我用 GDB + 调试代码调的)。

3) if (inp == ((void *)0))  这里:大部分人用的是 NULL ,但是用 ((void *)0) 会快些,具体参见 GCC 的优化选项。

4) 由于这题太简单,所以我没有写子函数。但这不是个好习惯,各位不要学习。


Icyblade 原创,转载请书上作者名字,谢谢合作!




May 24

回梦游仙 记5.12四川汶川大地震

回梦游仙 (歌词)

神州四月天
大地颠
震后巴蜀忧可怜
汶川县
都江堰
废墟一片
叠纸鸢
蜡烛点
举国上下心相连
夜无眠
只是叹流年
抗震救灾
你我紧上弦
有钱出钱
有力出力
上下一心
全力扭转乾坤
爱的歌声在回旋
先前千阡灰飞烟灭
大家重建家园
四月天
大地颠
震后巴蜀忧可怜
汶川县
都江堰
废墟一片
叠纸鸢
蜡烛点
举国上下心相连
夜无眠
只是叹流年
叹流年

本诗系 Icyblade Wise 原创。

若要转载请署上作者姓名,谢谢合作!

May 13

七律 记5.12汶川大地震

七律 离殇

        闻道汶川震滔滔

        军民抗灾气势豪

        万家破亡人轮回

        举国上下悲寂寥

        谁言重担不可挑

        神州大地尽舜尧

        深知情在身长在

        祥云御剑彩云飘

                        作于 二〇〇八年 四月 初十


本诗系 Icyblade Wise 原创。

若要转载请署上作者姓名,谢谢合作!

 

临风阁

Loading...Loading...
Welcome to visit!
Please wait...
Sorry, the comment you entered is too long. Please shorten it.
You didn't enter anything. Please try again.
Sorry, we can't add your comment right now. Please try again later.
To add a comment, you need permission from your parent. Ask for permission
Your parent has turned off comments.
Sorry, we can't delete your comment right now. Please try again later.
You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
Complete the security check below to finish leaving your comment.
The characters you type in the security check must match the characters in the picture or audio.
Junior-Suwrote:

Dear Dai Yuchao,

      I am so glad to find here,although, i am in a rage because it is impossible to leave a message without an account……

      I have to say that your poets are wonderful.Some of the words, however, are pretty ‘human-thundered’.Haha~

      If you are interested in who am i,please debarkation this Website[ My Zone ]:

 

         http://blog.sina.com.cn/u/1272218081

         i have some troubles these days,so i am fond of using English......

      Hope you have a good time with  Chinese Love Story Of Fairy and Sword !!!  forever !!!

 

                                                                                                                          All the best,

                                                                                                                                 Junior-Sun

July 31

Windows Media Player