1341(算數基本定理)
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.
Aladdin was about to enter to a magical cave, led by the evil sorcerer who disguised himself as Aladdin's uncle, found a strange magical flying carpet at the entrance. There were some strange creatures guarding the entrance of the cave. Aladdin could run, but he knew that there was a high chance of getting caught. So, he decided to use the magical flying carpet. The carpet was rectangular shaped, but not square shaped. Aladdin took the carpet and with the help of it he passed the entrance.
Now you are given the area of the carpet and the length of the minimum possible side of the carpet, your task is to find how many types of carpets are possible. For example, the area of the carpet 12, and the minimum possible side of the carpet is 2, then there can be two types of carpets and their sides are: {2, 6} and {3, 4}.
Input starts with an integer T (≤ 4000), denoting the number of test cases.
Each case starts with a line containing two integers: a b (1 ≤ b ≤ a ≤ 1012) where a denotes the area of the carpet and b denotes the minimum possible side of the carpet.
OutputFor each case, print the case number and the number of possible carpets.
2
10 2
12 2
Sample OutputCase 1: 1
Case 2: 2自己好垃圾,這道題竟然做了那麼長時間,這道題大意是[b, a]有多少對因數對。這道題打眼一看就知道是算數基本定理,但是不知道怎麼找到小於b的因數。列舉小於b的數,如果這個數能夠整除a的話,就減去。我先用了個素數篩1e6內的素數,因為如果這個數為非素數的話,即使大於1e6但是,一定存在個小於1e6的因子,一定不要忘記這個數為素數。推的時候一定不要忘記約束條件,我就把如果這是個大於1e6的素數這個條件忘了相關推薦
1341(算數基本定理)
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first m
Aladdin and the Flying Carpet LightOJ - 1341(算數基本定理)
題目連結:qaq 題意:找出符合的因子對數的個數 思路:知道算數基本定理後就簡單了(感覺和暴力的複雜度一樣啊QAQ。。難受) 附上程式碼: #include<cstdio> #include<cmath>
nefu 118 n!後面有多少個0(算數基本定理)
個數 算術 算數 end OS 因式分解 大於 一個數 family 題意:從輸入中讀取一個數n,求出n!中末尾0的個數。 思路:階乘後的數很大,不可能直接計算的,對於任意一個正整數,若對其進行因式分解,那麽其末尾的0必定可以分解為2*5,在這裏,每一個0必然和一個因子5對
LightOJ 1236 Pairs Forming LCM(算數基本定理)
i+1 clas while 包含 兩個 min family clu eof 題意:在a,b中(a,b<=n)(1 ≤ n ≤ 1014),有多少組(a,b) (a<b)滿足lcm(a,b)==n; 先來看個知識點: 素因子分解:n = p1 ^ e
UVA 10791——Minimum Sum LCM (算數基本定理)
題目連結 題目大意 : 給你一個數n,讓你將這個數分解成至少兩個數,對每一個分解式進行求和,算出其中最小的那一個。 為什麼按照算數基本定理算出來的數字就是最小的吶:因為每一個數字都可以運用算數基本定理進行分解,如果所用的因數不是所分解的這些質數,那麼
[LightOJ 1341] Aladdin and the Flying Carpet (算數基本定理(唯一分解定理))
題目 fly pro sca rime memset def bool tin 題目鏈接: https://vjudge.net/problem/LightOJ-1341 題目描述: 問有幾種邊長為整數的矩形面積等於a,且矩形的短邊不小於b 算數基本定理的知識點:https
LightOJ 1341 Aladdin and the Flying Carpet(算術基本定理)
LightOJ 1341 Aladdin and the Flying Carpet 題意: 輸入一個矩形面積,以及矩形邊長的最小值,已知矩形不是正方形,求有多少種邊長組合。 思路
算數基本定理(求一個數所有約數的個數)——一道OJ題目
#include <cstdio> #include <iostream> #include <map> #include <set> using namespace std; int min(int a,int b) { if(a>b) retur
[算數基本定理] LightOJ 1341
題目大意 給出面積n,和最短邊m,求能形成的矩形的個數(不能為正方形)。 題目思路 根據算數基本定理有: 1.每個數n都能被分解為:n=p1^a1*p2^a2*^p3^a3……
算數基本定理、約數定理
乘法 size idt post width 大於 spa bsp 其中 算數基本定理 內容 何一個大於1的自然數 N, 如果N不為質數,那麽N可以唯一分解成有限個質數的乘積 ,這裏 均為質數,其中指數ai是正整數,如果N為質數也很顯然 約數定理 內容 由算數基本定理
LightOJ-1336-Sigma Function (算術基本定理)
原題連結: Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes th
LightOJ-1236- Pairs Forming LCM (算術基本定理)
原題連結: Find the result of the following code: long long pairsFormLCM( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) for( int j
算數基本定理求約數個數
題目:最多約數問題 正整數x 的約數是能整除x的正整數,其約數的個數記為div(x),例如div(10)=4。 設a 和b 是兩個正整數,找出a 和b 之間約數個數最多的數x 的約數個數。 樣例輸入: 1 36 樣例輸出: 9 算數基本定理:又稱
hdu4479 (數學題)(算術基本定理)
題目大意 給定一個三元組\((x,y,z)\)的\(gcd\)和\(lcm\),求可能的三元組的數量是多少,其中三元組是的具有順序的 其中\(gcd\)和\(lcm\)都是32位整數範圍之內 由算術基本定理可以得知: 如果$k=gcd(m,n) \(則\) k_p=min(m_p,n_p)$ 如果\(
lightOj 1341Aladdin and the Flying Carpet 算數基本定理
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first
算數基本定理 B
Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime i
LightOJ 1236 Pairs Forming LCM(算術基本定理)
LightOJ 1236 Pairs Forming LCM 題意: long long pairsFormLCM( int n ) { long long res = 0;
1116】Ekka Dokka 【算數基本定理】
Ekka and his friend Dokka decided to buy a cake. They both love cakes and that’s why they want to share the cake after buying it. A
4196】Remoteland 【逆元+算數基本定理】
In the Republic of Remoteland, the people celebrate their independence day every year. However, as it was a long long time ago, nob
uva 10791 Minimum Sum LCM(算術基本定理)
大意:給出一個數字n,LCM(q1,q2,……,qk)=n,求解q1,a2……qk的最小和。 分析:剛開始讀錯題了(又讀錯T_T),是一系列的數字之和。 由算術基本定理,,同時,發現如果,是最小的,也就是說如果是由產生的,那麼積是最小的,同時是一定的。比如,得到: 那麼和