1087 有多少不同的值 (20 分)
生活随笔
收集整理的這篇文章主要介紹了
1087 有多少不同的值 (20 分)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
當(dāng)自然數(shù)?n?依次取 1、2、3、……、N?時,算式???有多少個不同的值?(注:??為取整函數(shù),表示不超過?x?的最大自然數(shù),即?x?的整數(shù)部分。)
輸入格式:
輸入給出一個正整數(shù)?N(2)。
輸出格式:
在一行中輸出題面中算式取到的不同值的個數(shù)。
輸入樣例:
2017輸出樣例:
1480 #include<iostream> using namespace std; const int maxn = 100100; int hashTable[maxn] = {0};int main(){int n;scanf("%d",&n);for(int i = 1; i <= n; i++){int temp = i/2 + i/3 + i/5;hashTable[temp]++;}int cnt = 0;for(int i = 0; i <= maxn; i++){if(hashTable[i] != 0) cnt++;}printf("%d",cnt);return 0; }?
轉(zhuǎn)載于:https://www.cnblogs.com/wanghao-boke/p/10433678.html
總結(jié)
以上是生活随笔為你收集整理的1087 有多少不同的值 (20 分)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 我的泡沫之夏剧情介绍
- 下一篇: 1088 三人行 (20 分)