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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

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-

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

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

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

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.

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.

Ripple(XRP): Can the XRP coin price break through the $4 mark this quarter? Ripple(XRP): Can the XRP coin price break through the $4 mark this quarter? Mar 04, 2025 am 06:15 AM

Ripple (XRP) Outlook: Can the altcoin season exceed $4? This article will explore whether Ripple (XRP) can break through the all-time high of $4 in the upcoming altcoin season. Despite the overall cryptocurrency market sluggish, XRP still has upside potential. Can XRP break through $4? Analysts predict XRP will rebound in the coming months, even reaching an all-time high of $4.12 on April 15, up nearly 80%. However, the average forecast price is around $3.12, and April 15 may be just a brief peak. XRP's cooperation with South Korea and the approval process of XRPETF will be key factors affecting its price. South Korea cooperation will increase XRP's market share in South Korea; and the approval of XRPETF will

How to add name to setup in Vue3 How to add name to setup in Vue3 May 13, 2023 am 09:40 AM

What is the use of name in Vue3? 1. Name needs to be defined when making recursive components. 2. The component can be cached with keep-aliveincludeexclude. 3. When Vue reports an error or is debugging, you can see the name of the component. Vue3 defines name1. It is automatically generated as long as the setup syntax sugar mode single file component is turned on in the script. The corresponding name option will be automatically generated based on the file name. For example, Tree.vue, then its name will be automatically generated by Tree. This has a drawback. If you want to modify the name, you need to modify the component name. If there is a place to import the component, you need to modify it together. 2. Open a script to define name

See all articles