Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:实现0MS啦!但是提交时间不同结果也不同啊!^_^,In Reply To:实现0MS啦!但是提交时间不同结果也不同啊!^_^, Posted by:CCUT06 at 2009-03-10 19:43:38 是因为服务器这时候比较空闲吧 > Problem: 3006 User: CCUT06 > Memory: 1216K Time: 0MS > Language: C++ Result: Accepted > > #include "iostream" > using namespace std; > const int max = 1000005; > bool prime[1000005] = {false}; > int main() > { > int i, > a, > d, > n, > j; > > //创建表 > memset(prime,true,sizeof(prime)); > > for(i = 3 ; i <= 1000 ; i += 2 ) > { > for(j = 3 ; j <= ::max / i ; j += 2) > { > if(prime[i]) > { > prime[i * j] = false; > } > } > } > for(i = 4 ; i <= ::max; i += 2 ) > { > prime[i] = false; > } > prime[1] = prime[0] = false; > > while(cin >> a >> d >> n,a != 0 && d != 0 && n != 0) > { > j = 0; > for (i = a; j < n; i += d) > { > if (prime[i]) > { > j++; > } > } > cout << i - d << endl; > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator