A. Multiplication Table
2015-09-15 20:46
274 查看
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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 ≤ 105, 1 ≤ x ≤ 109)
— 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.
Sample test(s)
input
output
input
output
input
output
Note
A table for the second sample test is given below. The occurrences of number 12 are marked bold.
解题说明:此题是一道水题,只需要判断两个数乘积是否为一个指定的数即可。
#include<stdio.h>
#include <string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a,b,i,count=0;
scanf("%d %d",&a,&b);
for(i=1;i<=a;i++)
{
if(b%i==0)
{
if((b/i)<=a)
{
count++;
}
}
}
printf("%d\n",count);
return 0;
}
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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 ≤ 105, 1 ≤ x ≤ 109)
— 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.
Sample test(s)
input
10 5
output
2
input
6 12
output
4
input
5 13
output
0
Note
A table for the second sample test is given below. The occurrences of number 12 are marked bold.
解题说明:此题是一道水题,只需要判断两个数乘积是否为一个指定的数即可。
#include<stdio.h>
#include <string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a,b,i,count=0;
scanf("%d %d",&a,&b);
for(i=1;i<=a;i++)
{
if(b%i==0)
{
if((b/i)<=a)
{
count++;
}
}
}
printf("%d\n",count);
return 0;
}
相关文章推荐
- Qt Creator设置窗口布局
- tomcat和java ee的安装和配置!
- MT6735系列及MT6753系列多合一驱动编译手册(一)
- VmWare下扩展虚拟机内系统centos6.6的硬盘分区空间(图文讲解)
- BZOJ 1127 [POI2008]KUP 最大子矩阵
- Xcode6 - 更改项目Copyright
- 原根
- UI03_UITextField
- c++11实现optional
- java 小小问题
- 集合(Collection集合)由来
- HDU 3555 Bomb (数位dp)
- c#Dictionary键值对的使用
- hdu5437Alisha’s Party set模拟
- 自定义Toast
- c#Dictionary键值对的使用
- 成为腾讯开发者——如何使用QQ开放平台和微信开放平台
- A+B for Input-Output Practice (IV)
- IOS开发把汉字转换成拼音的两种方法和返回拼音首字母
- 反射机制(字段)