• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    CodeforcesRound#282(Div.2)-B.ModularEquations_html/css

    來源:懂視網 責編:小采 時間:2020-11-27 15:59:41
    文檔

    CodeforcesRound#282(Div.2)-B.ModularEquations_html/css

    CodeforcesRound#282(Div.2)-B.ModularEquations_html/css_WEB-ITnose:Modular Equations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Last week, Hamed learned about a new type of equations in his math class called Modular Equa
    推薦度:
    導讀CodeforcesRound#282(Div.2)-B.ModularEquations_html/css_WEB-ITnose:Modular Equations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Last week, Hamed learned about a new type of equations in his math class called Modular Equa

    Modular Equations

    time limit per test

    1 second

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by . A Modular Equation, as Hamed's teacher described, is an equation of the form in which a and b are two non-negative integers and x is a variable. We call a positive integer x for which asolution of our equation.

    Hamed didn't pay much attention to the class since he was watching a movie. He only managed to understand the definitions of these equations.

    Now he wants to write his math exercises but since he has no idea how to do that, he asked you for help. He has told you all he knows about Modular Equations and asked you to write a program which given two numbers a and b determines how many answers the Modular Equation has.

    Input

    In the only line of the input two space-separated integers a and b (0?≤?a,?b?≤?109) are given.

    Output

    If there is an infinite number of answers to our equation, print "infinity" (without the quotes). Otherwise print the number of solutions of the Modular Equation .

    Sample test(s)

    input

    21 5

    output

    input

    9435152 272

    output

    282

    input

    10 10

    output

    infinity

    Note

    In the first sample the answers of the Modular Equation are 8 and 16 since




    題意:給出a,b,問有多少滿足a % x == b的正整數x存在。


    分析:暴力可解。a % x == b有(a - b) % x == 0,也就是找a - b的因子。前提是:x是正整數,但是要注意需滿足x > b(余數比除數小),當a < b時,此時沒有x滿足條件,輸出0即可;當a == b時,應輸出“infinity”;否則的話,直接暴力找a - b的因子即可。




    AC代碼:

    #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x7fffffffint main(){ #ifdef sxk freopen("in.txt","r",stdin); #endif int a, b, ans; while(scanf("%d%d",&a, &b)!=EOF) { ans = 0; if(a < b) puts("0"); else if(a == b) puts("infinity"); else{ int x; for(x=1; x*x b) ans ++; if((a-b)/x > b) ans ++; } } if((a-b) == x*x && x > b) ans ++; printf("%d\n", ans); } } return 0;}



    Python版:

    a, b = map(int, raw_input().split())if a == b: print 'infinity'elif a < b: print 0else: a -= b i = 1 ans = 0 while i*i <= a: if a % i == 0: if i > b: ans += 1 if a/i > b and i*i != a: ans += 1 i += 1 print ans

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    CodeforcesRound#282(Div.2)-B.ModularEquations_html/css

    CodeforcesRound#282(Div.2)-B.ModularEquations_html/css_WEB-ITnose:Modular Equations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Last week, Hamed learned about a new type of equations in his math class called Modular Equa
    推薦度:
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 久久久这里有精品中文字幕| 99久久99久久久精品齐齐| 成人午夜精品久久久久久久小说| 国产精品主播一区二区| 骚片AV蜜桃精品一区| 国产欧美日本精品| 成人国产精品秘 果冻传媒在线 | 久久97久久97精品免视看| 亚洲国产精品一区二区成人片国内| 国精品午夜福利视频不卡| 日本午夜精品理论片A级APP发布| 国产精品v欧美精品v日韩| 欧美精品一本久久男人的天堂| 亚洲精品无码久久千人斩| 精品国产成人在线| 国产高清国产精品国产专区| 国产精品国产三级国产专播 | MM1313亚洲精品无码| 久久久久人妻一区精品| 免费视频精品一区二区| 精品久久无码中文字幕| 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 | 久久96国产精品久久久| 精品久久久久久久久久中文字幕 | 国产女人18毛片水真多18精品 | 亚洲一区爱区精品无码| 国产精品成人观看视频免费| 国产精品成人无码久久久久久| 亚洲精品二三区| 国产精品99无码一区二区| 中文字幕精品亚洲无线码一区应用| 国产成人精品AA毛片| 久久国产成人亚洲精品影院| 久久精品www人人爽人人| 久久久无码精品亚洲日韩软件| 97精品国产91久久久久久| 亚洲福利精品电影在线观看| 日韩一级精品视频在线观看| 国产精品久久久亚洲| www.亚洲精品.com| 亚洲A∨午夜成人片精品网站|