#429. [CZOI2018 F] 量子计算
[CZOI2018 F] 量子计算
题目描述
做完基因锁手术后,小X又被机器狗带回到了会客舱,外星首领请小X喝了杯龙冠龙井,说道:“此茶乃 G20 峰会专用,对你的术后恢复大有裨益,在送你回地球之前,你可以再问一个问题。”小X问道:“人类这么多年都未能破译基因密码,你们是如何做到的呢?”外星首领答道:“这全靠我们的科学家发明的 位量子计算机,它的计算速度大约是 的 次方,而地球上最快的光电计算机目前最快能算到 的 次方左右。”小X梦醒之后上网查阅了一下有关量子计算机的最新发展状况,发现米国已经在研制 位的量子计算机了,联想到最近发生的中兴事件,小X心想一旦量子计算技术再受制于人,那后果就十分严重了,于是小X计划研制 位的量子计算机,他觉得这个任务有些艰巨,需要找几位天资聪颖且志同道合的小伙伴来帮助自己,于是就想到了这次的程序设计小能手比赛,小X出了下面这个题目来考考小朋友们,通过的同学将有机会跟小X一起研制量子计算机哦!
一个圆被均分成了 个区域,现有 种可供选择的颜色给图中的区域涂色,每一个区域只能涂一种颜色,且相邻的区域要涂不同的颜色,问有多少种不同的涂色方式?由于结果很大,你只要输出结果除以 的余数的值。
以下是 的时候的圆被分成的样子。
输入格式
输入数据仅有一行包含两个用空格隔开的正整数 ,即圆被分成了 个区域,有 种可供选择的颜色。
输出格式
输出数据仅有一行包含一个整数,表示不同的涂色方式,请输出对 求余后的值。
5 3
30
提示
的数据 。
$40\%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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