欢迎辞

欢迎来到“笃志以砺,决起而飞”!
如果您是第一次来到本站,建议访问本站导读以便更快地了解本站。
如果您喜欢本站,欢迎订阅

 

2012 年五月
« 四  
 123456
78910111213
14151617181920
21222324252627
28293031 

USACO Prime Palindromes (pprime)

这个程序是哈尔滨工业大学的一道作业题,有一位朋友昨晚让我看了这道题目,我发现这道题目还真不是那么简单。学校对刚刚学完数组的大一同学出此题目是否欠妥呢?

现在先看看题目。

Prime Palindromes

The number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds all prime palindromes in the range of two supplied numbers a and b (5 <= a < b <= 100,000,000); both a and b are considered to be within the range .
阅读全文 »

一葉知秋

    寫在前面:進入武漢大學以來,我最大的感受就是忙。各種各樣的事情讓人奔波不停,繁忙的生活似乎永遠沒有盡頭。有時候,我突然有一段時間沒有事情做,我會感到非常地不可思議,甚至有些恐慌。各種講座、學術會議琳琅滿目。繁忙,或許是每個這裡的學生共同的體會。課表排滿了週一到週五,各種實踐活動、比賽和社團活動充滿了課餘時間,而大家又都在不斷的發展自己的才藝和特長。但是我特別喜歡這種感覺,這樣過去的每一天都會感到很充實。

    大學入學以來,我已經逐漸認識了很多人,新的人際關係也開始逐漸建立。事情和人際忙的不可開交,我有時候會忙到沒空學自己感興趣的知識、沒空讀書、沒空寫博客、沒空吃飯、沒空洗澡、沒空睡覺……在這種情況下,本文的出現可以說是一個奇蹟。


阅读全文 »

Note: SSD1 1.1.1

Internet is a computer network that connects millions of computers across a number of countries. There is no central authority that controls the Internet; different organizations own different pieces of it. The Internet was originally conceived of by the Advanced Research Project Agency (ARPA) of the U.S. government in the 1960s.

The World Wide Web (or "the Web" for short) refers to that portion of the computers on the Internet that can communicate with each other using a computer-network protocol called HTTP. All browsers use HTTP to request and receive Web pages from other computers.

We have used the words page and place interchangeably when referring to the Web. Another synonymous term is site, as in Web site. All three terms refer to locations on the Web that you can visit and view through a browser.

An Internet Service Provider (ISP) is any one of a number of companies that enable people like you and me not only to connect to the Internet and surf the Web but also to publish Web pages.

There is no one to certify that the information presented on the Web is accurate<精確的>, correct, and up-to-date.

A search engine is a program that allows one to search for keywords in files at one or more Internet sites. Popular search engines include Lycos, Excite, and AltaVista.

Enjoy English : My expectation of learning English in the new term

Time goes by, I have been in International Software School of Wuhan University for my college for some days. My dream is to be a good programmer, a software architect, even aa boss of a IT company. I know it is so important to learn English for my major, for I will always have much time reading English articles, and may go to foreign countries for further study.

In high school, I have learned much English knowledge. In my opinion, I am not to study only the grammer or the word.

As for my expectation for this term, I select a word called ENJOY. So I plan to learn more than English itself. English culture, knowledge written in English language, and even everything else in English, will be my expectation.

With my growing up, I have realized that to learn is not only to get the knowledge, but also to gain the feeling of culture. I remember,when I study Chinese, I usually want to get the cultural background of the text. I also want to learn more about English culture in my subject. For this reason, I will read much more.

I want to start my morning-reading. I can not wait to sit in the picturesque university, reading aloud, making myself fly to the western countries. Enjoy the sunshine, the article, the happiness of learning English, and make a beautiful trip to everywhere in the world. How eagerly I expect it!

Read more, do more morning-reading, and listen more. I believe I will gain my sense of English which is my biggest target in this term. I will also know more about English culture.

(IT IS MY HOMEWORK FOR COLLEGE ENGLISH, EDITED WITH NAL’S HELP. THANKS)

USACO 1.3 Prime Cryptarithm (crypt1)

这道题目没有花费什么时间,基本上写完就 AC 了,不过在这道题目上倒是认识到一个问题。

函数 itoa, atoi 等并非标准的 C 函数库扩展,在很多网站上大量滥用这些函数,但这些函数只能用于 VC++ 等编译器。在 G++ 等编译器中是不适用的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
ID: cxj6661
LANG: C++
PROG: crypt1
*/
 
#include <fstream>
#include <string>
#include <stdio.h>
#include <memory.h>
 
using namespace std;
 
const char *infile = "crypt1.in";
const char *oufile = "crypt1.out";
 
bool can[10]; // define whether the number is used.
int use[5];
int l, res = 0;
 
// ** function declare **
bool check();
bool allin(char *s);
 
// change int into char* type.
#define tostr(d,to) \
{ \
	sprintf(to, "%d", d); \
}
 
inline void init() // read file.
{
	memset(can, false, sizeof(can));
	ios::sync_with_stdio(false);
	ifstream fin(infile);
	fin >> l;
	for (int i = 0, j; i < l; ++i)
	{
		fin >> j;
		can[j] = true;
	}
	fin.close();
}
 
inline void doit(int p) // dfs.
{
	if (p == 5) // has found a result of two numbers.
	{
		if (check())
			++res;
		return;
	}
	for (int i = 0; i < 10; ++i)
		if (can[i])
		{
			if ((p == 0 || p == 3) && i == 0)
				continue;
			use[p] = i;
			doit (p+1);
		}
}
 
inline bool check() // check whether it's a good result.
{
	int a = use[2] + use[1] * 10 + use[0] * 100, b = use[3] * 10 + use[4],c = a * use[4], d = a * use[3];
	if (c > 999 || d > 999 || c < 100 || d < 100)
		return false;
	char s1[10], s2[10];
	tostr(c, s1);
	tostr(d, s2);
	if ((!allin(s1)) || (!allin(s2)))
		return false;
	int e = c + d * 10;
	if (e > 9999 || e < 1000)
		return false;
	tostr(e, s1);
	if (!allin(s1))
		return false;
	return true;
}
 
inline bool allin(char *s) // is all number in the can array?
{
	for (int i = 0; i < strlen(s); ++i)
	{
		if (!can[s[i] - '0'])
		{
			return false;
		}
	}
	return true;
}
 
inline void output() // output the result.
{
	ofstream fout(oufile);
	fout << res << endl;
	fout.close();
}
 
int main(void)
{
	init();
	doit(0);
	output();
	return 0;
}
第 12 页,共 66 页« 最新...6789101112131415161718...304050...最旧 »