PAT Basic 1087 how many different values (20 points)

When the natural number  n order to take 1,2,3, ......, N, the equation  of how many different values ⌊ there? (Note: ⌊ to rounding function, represents no more than  x maximum natural number, i.e.  the integer part of x.)

Input formats:

Input gives a positive integer  N ( 2).

Output formats:

The number of different values ​​of the output face formula title in a row to take.

Sample input:

2017

Sample output:

1480

#include <iostream>
#include <unordered_map>
using namespace std;
int main(){
    unordered_map<int,int> m;
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        m[(i/2+i/3+i/5)]++;
    cout<<m.size();
    system("pause");
    return 0;
}

 

 

Guess you like

Origin www.cnblogs.com/littlepage/p/11618971.html