日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > > 充電吧
[導(dǎo)讀]題面:D - Human or Pig Time Limit:2000MS????Memory Limit:65536KB????64bit IO Format:%lld & %llu S

題面:


D - Human or Pig Time Limit:2000MS????Memory Limit:65536KB????64bit IO Format:%lld & %llu SubmitStatusPracticeZOJ 3513

Description

A man is lost in a strange world. In this world, he is a human in the daytime, and he will become a pig at night. The strange world is rectangle which is seperated into many 1 * 1 grids, from (0,0) to (X,Y). Every grid has a coordinate (x , y ). If he is in the grid ( x , y ), he can jump to grid (x - k * y , y ) or ( x , y - k * x ). k is a positive integer. For example, if he is in the grid (4,9), he can only jump to the grid (4,1) or (4,5). At night, he jumps to another grid at 1:00 AM as pig. In the daytime, he jumps to another grid at 1:00 PM as a human. So he will jump exactly twice everyday.

As the figure show, the grids ( x , 0 ), ( 0 , y ) (0 <= x <= X, 0 <=y <= Y ) are the river. When he Jump into the river, he will change from pig to human or change from human to pig immediately. And his property will never change from then on. It means that if he jump into the river in the daytime, he will be a pig forever. He want to jump into the river at night, so that he change from pig to human immediately, and can be a human forever, never become a pig again.

When he become a pig at night, he will jump to a grid whose coordinate satisfies (x - k * y , y ) or ( x , y - k * x ) arbitrarily. He will not jump out of the strange world either in the daytime or at night. At the beginning, he is at the grid (x0 , y0 ). To ensure that he can jump into the river as a pig at last, at the beginning, he can choose to start as a pig at night or as a human in the daytime. You need to determine what time (day or night) to start in every grid of the strange world excecpt the river. Use a matrix to display it.

Input

There are multiple cases (no more than 100).

Each case contain two integers X and Y (1 <= X * Y <= 40000) indicating the size of the strange world.

Output

For each test case i, print case number in the form "Case #i" in one single line. And there is aX*Y matrix. The j th charater of the i th line indicating what time (day or night) to start in the grid (i , j ). 'H' means that to ensure that he can jump into the river as a human, he needs to start as a human in the daytime. 'P' means that to ensure that he can jump into the river as a human, he needs to start as a pig at night.

Sample Input

1?2
2?3

Sample Output

Case?#1:
PH
Case?#2:
PHH
HPP



題目大意:

??? 給定一個初始坐標(biāo),(x,y)可以移動到(x-k*y,y)或者(x,y-k*x),k為正整數(shù)。初始給定的點在一張地圖上,地圖上的(x,0),(0,y)是一條神奇的河,跳進去就會發(fā)生身份的轉(zhuǎn)變,即豬變?nèi)?,人變豬,且不會再發(fā)生改變。很重要的一點是,狀態(tài)為豬是笨的,他的選擇是隨意的,而人的狀態(tài)是明智的,他是奔著最后可以變?yōu)槿说哪繕?biāo)去的。其實,當(dāng)x,y相對大小不變關(guān)系時,只能移動x,或者y。故比如x>y時,可以移動x/y次。那么就可以視這些可移動的為一個序列。進而可以轉(zhuǎn)換為取石子的模型,每次可移動的步數(shù),可以視為一堆石子。與普通取石子模型不同的是,這道題需要按固定順序取。因為,要保證最后那一跳是豬變?nèi)?,所以如果某個位置是填豬,也就是無論他怎么跳,最后都會跳到豬變?nèi)说臓顟B(tài),若某個位置填人,那么就是該位置,不能任由豬亂跳,需要人掌控。那么,人是如何做到掌控的呢,像一堆石子只有1個,人和豬是沒有選擇余地的,只能乖乖跳。但只要數(shù)量大于1,那么人就可以選擇,比如,是留一個給豬跳,還是全都自己跳。因此,只要數(shù)取石子序列從最開始開始的連續(xù)1的個數(shù),然后確保第一個出現(xiàn)大于1的位置是留給人的就ok啦。


代碼:


#include#include#include#include#includeusing?namespace?std;
int?cal(int?x,int?y)
{
	int?tc=0,tx=0;
	if(x<y)
	{
		x^=y;
		y^=x;
		x^=y;
	}
	while(1)
	{
		tx=x/y;
		if(tx==1)
		??tc++;
		else
		??break;
		x%=y;
		if(x==0)break;
		x^=y;
		y^=x;
		x^=y;
	}
	return?tc;
}
int?main()
{
??int?n,m,cnt=1,res;
??while(~scanf("%d%d",&n,&m))
??{
?????printf("Case?#%d:n",cnt++);
?????for(int?i=1;i<=n;i++)
?????{
		?for(int?j=1;j<=m;j++)
		?{
			?res=cal(i,j);
			?if(res%2)
			????printf("P");
			?else
			????printf("H");
	?????}
	?????printf("n");
	?}
??}
??return?0;
}



本站聲明: 本文章由作者或相關(guān)機構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

LED驅(qū)動電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: 驅(qū)動電源

在工業(yè)自動化蓬勃發(fā)展的當(dāng)下,工業(yè)電機作為核心動力設(shè)備,其驅(qū)動電源的性能直接關(guān)系到整個系統(tǒng)的穩(wěn)定性和可靠性。其中,反電動勢抑制與過流保護是驅(qū)動電源設(shè)計中至關(guān)重要的兩個環(huán)節(jié),集成化方案的設(shè)計成為提升電機驅(qū)動性能的關(guān)鍵。

關(guān)鍵字: 工業(yè)電機 驅(qū)動電源

LED 驅(qū)動電源作為 LED 照明系統(tǒng)的 “心臟”,其穩(wěn)定性直接決定了整個照明設(shè)備的使用壽命。然而,在實際應(yīng)用中,LED 驅(qū)動電源易損壞的問題卻十分常見,不僅增加了維護成本,還影響了用戶體驗。要解決這一問題,需從設(shè)計、生...

關(guān)鍵字: 驅(qū)動電源 照明系統(tǒng) 散熱

根據(jù)LED驅(qū)動電源的公式,電感內(nèi)電流波動大小和電感值成反比,輸出紋波和輸出電容值成反比。所以加大電感值和輸出電容值可以減小紋波。

關(guān)鍵字: LED 設(shè)計 驅(qū)動電源

電動汽車(EV)作為新能源汽車的重要代表,正逐漸成為全球汽車產(chǎn)業(yè)的重要發(fā)展方向。電動汽車的核心技術(shù)之一是電機驅(qū)動控制系統(tǒng),而絕緣柵雙極型晶體管(IGBT)作為電機驅(qū)動系統(tǒng)中的關(guān)鍵元件,其性能直接影響到電動汽車的動力性能和...

關(guān)鍵字: 電動汽車 新能源 驅(qū)動電源

在現(xiàn)代城市建設(shè)中,街道及停車場照明作為基礎(chǔ)設(shè)施的重要組成部分,其質(zhì)量和效率直接關(guān)系到城市的公共安全、居民生活質(zhì)量和能源利用效率。隨著科技的進步,高亮度白光發(fā)光二極管(LED)因其獨特的優(yōu)勢逐漸取代傳統(tǒng)光源,成為大功率區(qū)域...

關(guān)鍵字: 發(fā)光二極管 驅(qū)動電源 LED

LED通用照明設(shè)計工程師會遇到許多挑戰(zhàn),如功率密度、功率因數(shù)校正(PFC)、空間受限和可靠性等。

關(guān)鍵字: LED 驅(qū)動電源 功率因數(shù)校正

在LED照明技術(shù)日益普及的今天,LED驅(qū)動電源的電磁干擾(EMI)問題成為了一個不可忽視的挑戰(zhàn)。電磁干擾不僅會影響LED燈具的正常工作,還可能對周圍電子設(shè)備造成不利影響,甚至引發(fā)系統(tǒng)故障。因此,采取有效的硬件措施來解決L...

關(guān)鍵字: LED照明技術(shù) 電磁干擾 驅(qū)動電源

開關(guān)電源具有效率高的特性,而且開關(guān)電源的變壓器體積比串聯(lián)穩(wěn)壓型電源的要小得多,電源電路比較整潔,整機重量也有所下降,所以,現(xiàn)在的LED驅(qū)動電源

關(guān)鍵字: LED 驅(qū)動電源 開關(guān)電源

LED驅(qū)動電源是把電源供應(yīng)轉(zhuǎn)換為特定的電壓電流以驅(qū)動LED發(fā)光的電壓轉(zhuǎn)換器,通常情況下:LED驅(qū)動電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: LED 隧道燈 驅(qū)動電源
關(guān)閉