www.久久久久|狼友网站av天堂|精品国产无码a片|一级av色欲av|91在线播放视频|亚洲无码主播在线|国产精品草久在线|明星AV网站在线|污污内射久久一区|婷婷综合视频网站

當前位置:首頁 > 芯聞號 > 充電吧
[導讀]題面: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



題目大意:

??? 給定一個初始坐標,(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)槿说哪繕巳サ摹F鋵?,當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)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫毥谦F公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉(zhuǎn)型技術(shù)解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關(guān)鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務能7×24不間斷運行,同時企業(yè)卻面臨越來越多業(yè)務中斷的風險,如企業(yè)系統(tǒng)復雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會開幕式在貴陽舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會上,華為常務董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機 衛(wèi)星通信

要點: 有效應對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實提質(zhì)增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務引領(lǐng)增長 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競爭力 堅持高質(zhì)量發(fā)展策略,塑強核心競爭優(yōu)勢...

關(guān)鍵字: 通信 BSP 電信運營商 數(shù)字經(jīng)濟

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術(shù)學會聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(shù)(集團)股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉