zoukankan      html  css  js  c++  java
  • CF div2 319 A

    A. Multiplication Table
    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
    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.

    愚蠢的来了一发O(n^2)的暴力,简直太暴力了,后面发现直接枚举n就行了

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <iostream>
     4 #include <queue>
     5 #include <vector>
     6 #include <stack>
     7 
     8 using namespace std;
     9 
    10 const int M = 10005;
    11 const int maxn = 5000000;
    12 typedef long long ll;
    13 
    14 vector<int>G[maxn];
    15 queue<int>Q;
    16 stack<int>st;
    17 
    18 
    19 int a[maxn];
    20 
    21 int main()
    22 {
    23 
    24    long long n,i;
    25     long long ans = 0;
    26     int cnt = 0;
    27     long long x;
    28     scanf("%lld%lld",&n,&x);
    29     for( i=1;i<=n;i++){
    30         if(x%i==0&&i!=1&&x/i<=n){
    31             ans++;
    32         }
    33     }
    34     if(n>=x) ans++;
    35      printf("%lld
    ",ans);
    36     return 0;
    37 }
  • 相关阅读:
    JavaScript创建对象
    php 用户访问菜单页面,必须登录,判断用户是否登录
    ThinkPHP 3.1.2 控制器的模块和操作
    商业智能数据营销该怎么做?
    HTML::Entities 编码或解码 HTML 实体的字符串
    perl 处理json 数组格式
    打开redis服务提示
    Windwos 08R2_DNS+AD安装图文
    Windwos 08R2_DNS+AD安装图文
    单选按钮和标签组合点击
  • 原文地址:https://www.cnblogs.com/lmlyzxiao/p/4814753.html
Copyright © 2011-2022 走看看