<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答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
        主站蜘蛛池模板: 亚洲av午夜成人片精品电影| 亚洲精品影院久久久久久| 国产精品亚洲一区二区麻豆| 91九色视频无限观看免费| 国产免费黄色大片| 337p日本欧洲亚洲大胆色噜噜| 亚洲.国产.欧美一区二区三区| 国产一级片免费看| 日本成人在线免费观看| 亚洲乱妇老熟女爽到高潮的片| 免费人成在线视频| 亚洲麻豆精品果冻传媒| 99免费视频观看| 亚洲一区二区三区在线网站| 处破痛哭A√18成年片免费| 亚洲精品无码一区二区| 免费日韩在线视频| 亚洲黄片手机免费观看| 亚洲国产天堂在线观看| 国产精品免费久久久久电影网| 亚洲无人区午夜福利码高清完整版| 国产视频精品免费视频| 国产免费卡一卡三卡乱码| 美女黄频视频大全免费的| 国产三级在线观看免费| 亚洲成a∨人片在无码2023 | 亚洲AV之男人的天堂| 国产成人精品免费大全| 亚洲美女免费视频| 成人永久免费高清| 你是我的城池营垒免费观看完整版| 67pao强力打造67194在线午夜亚洲| 一本岛高清v不卡免费一三区| 亚洲av午夜国产精品无码中文字 | 亚洲第一成年男人的天堂| 中文字幕无码播放免费| 老子影院午夜伦不卡亚洲| 亚洲国产精品无码久久一区二区| 亚洲一级毛片免费观看| 偷自拍亚洲视频在线观看99| 久久精品国产亚洲AV麻豆不卡|