国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 礼泉县| 建瓯市| 左云县| 闸北区| 肇东市| 尉氏县| 喀喇沁旗| 新巴尔虎右旗| 长岭县| 突泉县| 镇康县| 滨州市| 青铜峡市| 黑山县| 治县。| 年辖:市辖区| 湖口县| 冷水江市| 郴州市| 文水县| 宜兴市| 宾阳县| 莱芜市| 望都县| 迁西县| 佛学| 通许县| 清水县| 宜兴市| 平和县| 苍溪县| 蓬溪县| 信宜市| 万载县| 保靖县| 尉氏县| 朔州市| 赞皇县| 九寨沟县| 蕉岭县| 玉溪市|