国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

hdu5512pagodas(最小公因數)

2019-11-08 19:56:31
字體:
來源:轉載
供稿:網友

題目描述:

PRoblem Descriptionn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two of them (labelled aand b, where 1≤a≠b≤n) withstood the test of time.Two monks, Yuwgna and Iaka, decide to make glories great again. They take turns to build pagodas and Yuwgna takes first. For each turn, one can rebuild a new pagodas labelled i (i?{a,b} and 1≤i≤n) if there exist two pagodas standing erect, labelled j and k respectively, such that i=j+k or i=j?k. Each pagoda can not be rebuilt twice.This is a game for them. The monk who can not rebuild a new pagoda will lose the game. InputThe first line contains an integer t (1≤t≤500) which is the number of test cases.For each test case, the first line provides the positive integer n (2≤n≤20000) and two different integers a and b. OutputFor each test case, output the winner (``Yuwgna" or ``Iaka"). Both of them will make the best possible decision each time. Sample Input
162 1 23 1 367 1 2100 1 28 6 89 6 810 6 811 6 812 6 813 6 814 6 815 6 816 6 81314 6 81994 1 131994 7 12 Sample Output
Case #1: IakaCase #2: YuwgnaCase #3: YuwgnaCase #4: IakaCase #5: IakaCase #6: IakaCase #7: YuwgnaCase #8: YuwgnaCase #9: IakaCase #10: IakaCase #11: YuwgnaCase #12: YuwgnaCase #13: IakaCase #14: YuwgnaCase #15: IakaCase #16: Iaka題目理解:代碼:
#include <iostream>#include <cmath>using namespace std;int gcd(int a,int b){    if(b==0)    return a;    else    return gcd(b,a%b);}int main(){    int t;    cin>>t;    for(int i=1;i<=t;i++)    {        int n,a,b;        cin>>n>>a>>b;        cout<<"Case #"<<i<<": ";        int tmp=gcd(a,b);        if(tmp==1)        {            if(n%2)            cout<<"Yuwgna"<<endl;            else            cout<<"Iaka"<<endl;        }        else        {            int ans=n/tmp;            if(ans%2)            cout<<"Yuwgna"<<endl;            else            cout<<"Iaka"<<endl;        }    }    return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 越西县| 来宾市| 武穴市| 沁阳市| 五华县| 张家港市| 潼关县| 崇义县| 贵阳市| 闽侯县| 稷山县| 新蔡县| 无极县| 土默特左旗| 蓝山县| 关岭| 库伦旗| 长兴县| 昭平县| 昆山市| 海原县| 桃源县| 天镇县| 勐海县| 永清县| 张家界市| 精河县| 德清县| 明光市| 大理市| 涿州市| 江陵县| 黑龙江省| 高碑店市| 肥西县| 南涧| 雅安市| 阳原县| 铁岭县| 益阳市| 会东县|