Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Let's consider a table consisting of n rows and n columns.
- The cell located at the intersection of i-th row and j-th column contains number i × j.
- The rows and columns are numbered starting from 1.
- You are given a positive integer x.
- Your task is to count the number of cells in a table that contain number x.
- Input:
- The single line contains numbers n and x (1 ≤ n ≤ 10^5, 1 ≤ x ≤ 10^9) —
- the size of the table and the number that we are looking for in the table.
- Output:
- Print a single number: the number of times x occurs in the table.
- Examples:
- input
- 10 5
- output
- 2
- input
- 6 12
- output
- 4
- input
- 5 13
- output
- 0
- */
- #include <iostream>
- #include <cstdio>
- #include <vector>
- #include <set>
- #include <map>
- #include <algorithm>
- #include <iterator>
- #include <string>
- #include <math.h>
- using namespace std;
- typedef long long int64;
- int main()
- {
- //freopen("input.txt", "r", stdin);
- int64 n, x, qty = 0;
- cin >> n >> x; // n - table size, x - the seeking number
- for (int i = 1; i <= n; i++) // checking all lines in the table
- {
- if (x % i == 0 && x / i <= n) // if there exists a number j that i * j = x and this j <= n (is on the table) then we increase qty
- {
- qty++;
- }
- }
- cout << qty << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment