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 }
  • 相关阅读:
    [译]理解 iOS 异常类型 <🌟>
    LeetCode 24. 两两交换链表中的节点
    解决The operation couldn’t be completed. Unable to log in with account
    <Typora> 常用操作快捷键
    LeetCode 23. 合并K个升序链表
    CSS盒子模型
    CCS属性
    CSS
    form表单
    html
  • 原文地址:https://www.cnblogs.com/lmlyzxiao/p/4814753.html
Copyright © 2011-2022 走看看