zoukankan      html  css  js  c++  java
  • Codeforces Codeforces Round #319 (Div. 2) A. Multiplication Table 水题

    A. Multiplication Table

    Time Limit: 1 Sec  

    Memory Limit: 256 MB

    题目连接

    http://codeforces.com/contest/577/problem/A

    Description

    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 Input

    10 5

    Sample Output

    2

    HINT

    题意

    给你n,m,相当于给了你一个n*n的乘法表,然后问你这个乘法表里面有多少个格子等于m

    题解:

    sqrt暴力枚举因子就好了

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <bitset>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 200500
    #define mod 1001
    #define eps 1e-9
    #define pi 3.1415926
    int Num;
    //const int inf=0x7fffffff;
    const ll inf=999999999;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    //*************************************************************************************
    
    
    int main()
    {
        int n=read(),x=read();
        int ans=0;
        for(int i=1;i<=sqrt(x);i++)
        {
            if(x%i==0)
            {
                if(i<=n&&x/i<=n)
                    ans+=2;
                if(i<=n&&i==x/i)
                    ans--;
            }
        }
        cout<<ans<<endl;
    }
  • 相关阅读:
    IOS7笔记-10、多线程、滚动视图
    IOS7笔记-8、协议、block、动画
    IOS7笔记- 7、视图、绘制、手势识别
    IOS7笔记-6、控制器多态性、导航控制器、选项卡栏控制器
    IOS7笔记-5、视图控制器生命周期
    C# DevExpress之GridView同步滚动条记录方法
    C# 隐藏TabControl标签
    VC++ 如何识别系统语言类别
    我的免费空间网站
    慕课网-Java入门第一季-7-5 Java 中带参无返回值方法的使用
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4800618.html
Copyright © 2011-2022 走看看