杰拉斯的博客

[ACM_NYOJ_270]Product of Digits

杰拉斯 杰拉斯 | 时间:2012-04-20, Fri | 17,931 views
编程算法 

Product of Digits

Time Limit: 1.0 second
Memory Limit: 16 MB

Description

Your task is to find the minimal positive integer number Q so that the product of digits of Q is exactly equal to N.

Input

The input contains the single integer number N (0 ≤ N ≤ 109).

Output

Your program should print to the output the only number Q. If such a number does not exist print −1.

(阅读全文…)

偶有小感

杰拉斯 杰拉斯 | 时间:2012-04-19, Thu | 10,296 views
心路历程 

一直在努力变成一个优秀的人,努力假装自己很勇敢,假装自己很外向,假装自己很坚强,假装自己无所谓地活着,其实我很胆怯,很内向,很脆弱,很想得到别人的认可。。努力的很辛苦,但回头想想还是不知道自己到底收获了什么。。。其实或许自己连想要什么都不清楚。。。我也想像有些人那样,很努力地去学课内的东西,即使自己不喜欢,也想像有些人那样,堕落到底,毫无压力地游戏人生。。。可我做不到,我也想平静地活着,可我不甘平凡,我想努力成功,可我起点太低,我想让别人看到自己在努力,可别人却完全不放在眼里。。。

不过偶有小感,明早起来还是得继续乐观坚强地努力下去。

[ACM_HDU_1009]FatMouse' Trade(贪心入门)

杰拉斯 杰拉斯 | 时间:2012-04-18, Wed | 21,856 views
编程算法 

FatMouse' Trade

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 22404 Accepted Submission(s): 6972

Description

FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.
The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse does not have to trade for all the JavaBeans in the room, instead, he may get J[i]* a% pounds of JavaBeans if he pays F[i]* a% pounds of cat food. Here a is a real number. Now he is assigning this homework to you: tell him the maximum amount of JavaBeans he can obtain.

Input

The input consists of multiple test cases. Each test case begins with a line containing two non-negative integers M and N. Then N lines follow, each contains two non-negative integers J[i] and F[i] respectively. The last test case is followed by two -1's. All integers are not greater than 1000.

Output

For each test case, print in a single line a real number accurate up to 3 decimal places, which is the maximum amount of JavaBeans that FatMouse can obtain.

(阅读全文…)

[ACM_NYOJ_15]括号匹配(二)

杰拉斯 杰拉斯 | 时间:2012-04-18, Wed | 17,765 views
编程算法 

括号匹配(二)

时间限制:1000 ms | 内存限制:65535 KB
难度:6

描述

给你一个字符串,里面只包含"(",")","[","]"四种符号,请问你需要至少添加多少个括号才能使这些括号匹配起来。
如:
[]是匹配的
([])[]是匹配的
((]是不匹配的
([)]是不匹配的

输入

第一行输入一个正整数N,表示测试数据组数(N<=10)
每组测试数据都只有一行,是一个字符串S,S中只包含以上所说的四种字符,S的长度不超过100

输出

对于每组测试数据都输出一个正整数,表示最少需要添加的括号的数量。每组测试输出占一行

(阅读全文…)

[ACM_NYOJ_2]括号匹配(一)

杰拉斯 杰拉斯 | 时间:2012-04-18, Wed | 16,750 views
编程算法 

括号配对问题

时间限制:3000 ms | 内存限制:65535 KB
难度:3

描述

现在,有一行括号序列,请你检查这行括号是否配对。

输入

第一行输入一个数N(0<N<=100),表示有N组测试数据。后面的N行输入多组输入数据,每组输入数据都是一个字符串S(S的长度小于10000,且S不是空串),测试数据组数少于5组。数据保证S中只含有"[","]","(",")"四种字符

输出

每组输入数据的输出占一行,如果该字符串中所含的括号是配对的,则输出Yes,如果不配对则输出No。

(阅读全文…)