整除个数

整除个数

题目描述
1、2、3...n 这 n 个数中有多少个数可以被正整数 b 整除。(0<n<=1000000000)

输入
输入包含多组数据,每组数据占一行,每行给出两个正整数 n、b。

输出
输出每组数据相应的结果。

样例输入
2 1
5 3
10 4

样例输出
2
1
2

C 实现

#include<stdio.h>
int main()
{
    long long n, b;
    while (scanf("%lld%lld", &n, &b) != EOF)
    {
        printf("%lld
", n / b);
    }
    return 0;
}

C++ 实现

#include<iostream>
using namespace std;
int main()
{
    long long n, b;
    while (cin >> n >> b)
    {
        cout << n / b << endl;
    }
    return 0;
}

运行结果

原文地址:https://www.cnblogs.com/hgnulb/p/8966093.html