多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > Facebook Hacker Cup 2015 Round 1 Homework(附帶測試數據)

Facebook Hacker Cup 2015 Round 1 Homework(附帶測試數據)

來源:程序員人生   發布時間:2015-01-26 09:01:48 閱讀次數:3309次


題目描寫:


Homework10 points
                                             
  •                   

Your first-grade math teacher, Mr. Book, has just introduced you to an amazing new concept ― primes! According to your notes, a prime is a positive integer greater than 1 that is divisible by only 1 and itself.

Primes seem fun, but without giving you and your 6-year-old colleagues time to consider their implications, he's promptly gone on to define another term: primacity. He explains that the primacity of an integer is the number of distinct primes which divide it. For example, the primacity of 12 is 2 (as it's divisible by primes 2 and 3), the primacity of 550 is 3 (as it's divisible by primes 2, 5, and 11), and the primacity of 7 is 1 (as the only prime it's divisible by is 7).

Following his lesson, Mr. Book has given you homework with some rather mean questions of the following form: Given 3 integers AB, and K, how many integers in the inclusive range [AB] have a primacity of exactly K?

Mr. Book probably expects his little homework assignment to take you and your classmates the rest of the year to complete, giving him time to slack off and nap during the remaining math classes. However, you want to learn more things from him instead! Can you use the skills you've learned in your first-grade computer science classes to finish Mr. Book's homework before tomorrow's math class?

Input

Input begins with an integer T, the number of homework questions. For each question, there is one line containing 3 space-separated integers: AB, and K.

Output

For the ith question, print a line containing "Case #i: " followed by the number of integers in the inclusive range [AB] with a primacity of K.

Constraints

1 ≤ T ≤ 100 
2 ≤ A ≤ B ≤ 107 
1 ≤ K ≤ 109 

Explanation of Sample

In the first test case, the numbers in the inclusive range [5, 15] with primacity 2 are 6, 10, 12, 14, and 15. All other numbers in this range have primacity 1.

Example input ?
Example output ?        
5 5 15 2 2 10 1 24 42 3 1000000 1000000 1 1000000 1000000 2
Case #1: 5 Case #2: 7 Case #3: 2 Case #4: 0 Case #5: 1











                                









解題思路:

這個題很水,打個表就過了。這個表記錄的是某個數有多少個質因數。表的處理方式類似于篩素數。


題目代碼:


#include <set> #include <map> #include <queue> #include <math.h> #include <vector> #include <string> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <cctype> #include <algorithm> #define eps 1e⑴0 #define pi acos(⑴.0) #define inf 107374182 #define inf64 1152921504606846976 #define lc l,m,tr<<1 #define rc m + 1,r,tr<<1|1 #define zero(a) fabs(a)<eps #define iabs(x) ((x) > 0 ? (x) : -(x)) #define clear1(A, X, SIZE) memset(A, X, sizeof(A[0]) * (min(SIZE,sizeof(A)))) #define clearall(A, X) memset(A, X, sizeof(A)) #define memcopy1(A , X, SIZE) memcpy(A , X ,sizeof(X[0])*(SIZE)) #define memcopyall(A, X) memcpy(A , X ,sizeof(X)) #define max( x, y ) ( ((x) > (y)) ? (x) : (y) ) #define min( x, y ) ( ((x) < (y)) ? (x) : (y) ) using namespace std; const int M = 10000007; int f[M]; void pri() { int t = 0; for(int i = 2; i <= M; i++) { if(!f[i]) { f[i]++; for(int j=2;i*j<=M;j++) { f[i*j]++; } } //printf("%d %d ",f[i] ,i); } } int main() { //freopen("data.txt","w",stdout); pri(); int t,case1=1; while(scanf("%d",&t)!=EOF) { while(t--) { int a,b,k,ans; scanf("%d%d%d",&a,&b,&k); ans=0; for(int i=a;i<=b;i++) { if(f[i]==k)ans++; } printf("Case #%d: %d ",case1++,ans); } } return 0; }


題目終究測試數據:

鏈接: http://pan.baidu.com/s/1yGmqa 

密碼: c5t1




生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 免费国产精成人品 | 亚洲经典一区 | 精品伊人久久大香线蕉网站 | 亚洲一区精品视频在线 | 国产永久免费高清动作片www | 午夜精品同性女女 | 午夜写真福利视频在线观看 | 91伊人久久| 免费观看男女羞羞的视频网站 | 国产精品日韩欧美一区二区三区 | 日本大蕉香蕉大视频在线观看 | 久草在线播放视频 | 欧美成人午夜精品一区二区 | 免费 欧美 自拍 在线观看 | 精品久久久久久影院免费 | 91精品视频网站 | 欧美亚洲国产片在线观看 | www.逼逼| 亚洲美女激情视频 | www.91久久| 亚洲免费网站观看视频 | 叼嘿视频在线观看免费 | 天堂在线xw | 国产精品短篇二区 | 在线免费观看亚洲 | 亚洲一级色 | 一本到亚洲网 | 波多野结衣中文字幕在线视频 | 欧美一区二区三区在线播放 | 永久在线观看www免费视频 | 欧美午夜三级我不卡在线观看 | 狂野欧美性猛交xxxx乱大交 | 精品成人在线视频 | 毛片毛片毛片毛片出来毛片 | 免费一级a毛片 | 九九精品免费观看在线 | 校园 图片区 视频 小说专区 | 亚洲欧美一区二区视频 | 国产成人精品免费视频网页大全 | 毛片大片 | 亚洲国产欧美精品一区二区三区 |