国产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 | 欧美日韩国产va另类 | 亚洲欧美日韩色图 | 国产精品一区二区久久 | 色yeye在线观看 | 午夜免费啪啪 | 久久久网久久久久合久久久久 | 日本三级全黄三级a | 欧美日韩国产另类一区二区三区 | 欧美另类色图 | 一级黄免费 | 久久久久久久久国产 | 亚洲综合欧美日韩 | 91精品欧美| 国模精品一区二区 | 国产精品高清一区二区三区不卡 | 欧美一级久久久久久久大片 | 国产91在线 | 日本 | 女人与公拘交酡全过程 | 久久久久久久国产高清 | 精品国产一区二区三区久久影院 | 日韩精品影视 | 最新国产网站 | 国产精品第一 | 不卡日本 | 欧美精品aaa久久久影院 | 久久婷婷色一区二区三区 | 日韩免费播放 | 欧美在线视频网站 | 国产成人欧美一区二区三区vr | 中文字字幕码一二三区 | 久久久久国产成人精品亚洲午夜 | 日本我不卡 | 国产精品国产三级国产普通话一 | 日本免费大黄 | 欧美在线视频一区二区 | 中文字幕亚洲综合 | 亚洲色图第一页 |