Home Database Mysql Tutorial USACO 1.2.3 Name That Number

USACO 1.2.3 Name That Number

Jun 07, 2016 pm 03:01 PM
name u

USACO 1.2.3 Name ThatNumber 题意:有好多头奶牛,它们每一头都有一个编号,每个数字分别对应三个字母,每个数字从它对应的字母中挑一个出来组成一个单词,给定一个词典,看如果这个单词在词典中是存在的,就输出,如果存在多个这样的单词,按照字母表的顺

USACO  1.2.3 Name ThatNumber

     题意:有好多头奶牛,它们每一头都有一个编号,每个数字分别对应三个字母,每个数字从它对应的字母中挑一个出来组成一个单词,给定一个词典,看如果这个单词在词典中是存在的,就输出,如果存在多个这样的单词,按照字母表的顺序输出。

     打印出所有可能的单词然后去比较,觉得效率有问题。出题者的用意明显是让我们反过来做,将词典里的单词转换成数字然后和给定的数字比较,因为给的词典里的单词都是按照字母表顺序排列的,而且数字和字母之间存在明显关系。

     细节+代码:

 

    

/*  
ID: 15257142  
LANG: C  
TASK: namenum 
*/  
#include<stdio.h>
#include<string.h>
int main(){
	freopen("namenum.in", "r", stdin); //在我看来输入输出是这道题目全部价值所在。
	char num[20],a[30],b[20];
	int m,ma,i,f,k;
	scanf("%s",num);
	m = strlen(num)-1;
	freopen("dict.txt", "r", stdin); //!
	freopen("namenum.out", "w", stdout); //!
	f = 0;
	while(scanf("%s",a)!=EOF){
		ma = strlen(a)-1;
		if(m!=ma)
			continue;
		for(i = 0;i'Q') //是没有'Q'的,那么……
				k = (a[i]-'B')/3;
			else
				k = (a[i]-'A')/3;
			b[i] = k+'2';
		}
		b[ma+1] = '\0';
		if(strcmp(b,num)==0){
			printf("%s\n",a);
			f = 1;
		}
	}
	if(f==0)
		printf("NONE\n");
	fclose(stdin);
	fclose(stdout);
	return 0;
}</string.h></stdio.h>
Copy after login


 

 


 

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
Looking up to the U9: China's new favorite electric supercar Looking up to the U9: China's new favorite electric supercar Oct 13, 2023 pm 03:37 PM

Driven by the era of automotive electrification, China's domestic automakers are actively involved in the production of electric supercars. Recently, Haopin, a high-end electric brand owned by GAC Aian, launched an electric supercar called SSR. Previously, BYD's Yangwang U9 also received widespread attention. Recently, a video was circulated on the Internet, purportedly showing Yangwang. U9 test video. In the video, a U9 is speeding on the track. Surprisingly, the vehicle's brake discs flash bright orange, making it look like it is competing in the 24 Hours of Le Mans. Particularly striking is the fact that the brake discs on the front wheels are at least twice as bright as those on the rear wheels. However, it is impossible to determine from the video whether the flash of light is caused by the flames produced by the brake discs during braking or whether it is the lighting effect of the vehicle. exhaust

How to solve the problem of win7 numeric keyboard u changing to 4 How to solve the problem of win7 numeric keyboard u changing to 4 Jul 14, 2023 am 08:49 AM

When some Win7 laptop customers use the numeric keyboard, they encounter the reason why they type u but it becomes 4. what happen? In fact, this is because your laptop has the keyboard integrated into the letter keys. You can fix this problem by simply closing the keyboard. The specific steps are as follows: FN+nunlock key conversion can input English letters normally. This method can also be used if the customer encounters pressing I to change to 5. How to solve the problem that the win7 numeric keyboard u becomes 4:1. For better convenience, the laptop does not have a small keyboard area. Therefore, there are keys that define the function of the numeric keypad. You can use the FN+nunlock key to convert. Some must use shift+numlock to enter English or data. 2.Numpad-

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

List of handling fees for okx trading platform List of handling fees for okx trading platform Feb 15, 2025 pm 03:09 PM

The OKX trading platform offers a variety of rates, including transaction fees, withdrawal fees and financing fees. For spot transactions, transaction fees vary according to transaction volume and VIP level, and adopt the "market maker model", that is, the market charges a lower handling fee for each transaction. In addition, OKX also offers a variety of futures contracts, including currency standard contracts, USDT contracts and delivery contracts, and the fee structure of each contract is also different.

What currency is virtual currency? Where to buy it? What currency is virtual currency? Where to buy it? Mar 04, 2025 pm 05:42 PM

The article introduces that virtual currency is a digital or virtual currency form that relies on cryptography and trades through peer-to-peer networks, and lists common currencies such as Bitcoin. It is usually available on cryptocurrency exchanges such as Coinbase, and all the advantages and disadvantages of each transaction. It emphasizes that the purchase of virtual currency is high, the price fluctuates greatly, and is prone to fraud and hacking. It reminds you to conduct sufficient research before investing and only invest in funds that can bear losses. The information is for reference only and is not investment advice.

How to install UFIDA U8Win10: simple tutorial How to install UFIDA U8Win10: simple tutorial Jan 09, 2024 pm 02:01 PM

When we use the win10 operating system, some friends need to use UF u8 on the computer because of work but don’t know how to operate it. Regarding this problem, the editor thinks that we can download UF u8 online first, and then go through the properties of the computer. Just make the corresponding settings, such as changing the computer name, modifying the registry, etc. Let’s take a look at how the editor did it for the detailed steps~ UFIDA u8win10 installation tutorial step 1: 1. On the “This PC” icon, select “Properties”; 2. Click Change under computer name, domain and workgroup settings Setting button: 3. Click on the "Computer Name" tab and enter the name that needs to be modified in the computer name field (English letters within 8 digits, excluding punctuation and special symbols); 4.

What should I do if php cannot get the name? What should I do if php cannot get the name? Nov 24, 2022 am 09:56 AM

PHP cannot get the name because when the name and id values ​​of the form element are different, the browser cannot recognize it. The solution: 1. Check whether some form elements and frame elements use name; 2. Check only Elements that can be assigned ID but not name; 3. For multi-select box checkbox, you can use "join(',', $__POST['name'])" to form data.

What does tron ​​ecosystem mean? What coins are there on the tron ​​chain? What does tron ​​ecosystem mean? What coins are there on the tron ​​chain? Feb 16, 2025 am 06:27 AM

TRON, a decentralized content entertainment platform based on blockchain technology, provides a comprehensive ecosystem that supports a variety of digital assets. The most well-known currency on the TRON chain is TRONIX (TRX), a practical token used to pay transaction fees and provide network incentives.

See all articles