[恢]hdu 2521
生活随笔
收集整理的這篇文章主要介紹了
[恢]hdu 2521
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2011-12-20 06:44:37
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2521
題意:中文。
mark:反素數直接for for暴力求,約莫計算不到10w次。查詢可用ST算法,但這題沒必要,直接掃就好了。
代碼:
# include <stdio.h>int factor[5010] ;
void init()
{
int i, j ;
for (i = 2 ; i <= 5000 ; i++)
{
for (j = i ; j <= 5000 ; j+= i)
factor[j] ++ ;
}
}
int main()
{
int T, a, b, i, ans ;
init() ;
scanf ("%d", &T) ;
while (T--)
{
scanf ("%d%d", &a, &b) ;
ans = a ;
for (i = a+1 ; i <= b ; i++)
if (factor[i] > factor[ans]) ans = i ;
printf ("%d\n", ans) ;
}
return 0 ;
}
轉載于:https://www.cnblogs.com/lzsz1212/archive/2012/01/06/2315268.html
總結
以上是生活随笔為你收集整理的[恢]hdu 2521的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JAVA中Map集合的使用举例
- 下一篇: [恢]hdu 2117