国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答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 | 看全色黄大色大片免费久久 | 韩日一区二区三区 | 国产日韩欧美一区二区三区视频 | 日本vs欧美一区二区三区 | 欧美日韩另类综合 | 免费一级a毛片在线播放直播 | 成人特黄午夜性a一级毛片 成人国产一区二区三区精品 | 日本欧美另类 | 99热成人精品国产免国语的 | 国产最新网站 | 亚洲欧洲日韩国产 | 中文字幕一区久久久久 | 国产视频一二三区 | 国产一区二区三区成人久久片 | 欧美在线视频观看 | 亚洲欧美精选 | 精品国产欧美一区二区五十路 | 特一级大黄在线观看 | 91系列在线观看免费 | 亚洲va欧美ⅴa国产va影院 | 欧美 日韩 中文字幕 | 亚洲第一欧美 | 亚洲精品小视频 | 亚洲国产欧美自拍 | 欧美极品尤物在线播放一级 | 韩国在线视频 | 欧美日韩另类综合 | 亚欧成人毛片一区二区三区四区 | 日韩欧美精品一区二区三区 | 好看的电影网站亚洲一区 | 成人播放| 精品一成人岛国片在线观看 | 国产综合一区二区 | 欧美视频日韩视频 | 日韩欧美色 | 免费国产小视频在线观看 | 国产一级α片 | 91久热| 亚洲国产精品成人综合久久久 | 国产日韩欧美视频在线观看 |