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 |
本方法改进0MS 不需公式(附码)#include <iostream> #include <cmath> using namespace std; int res(int num) { int n , i, t = sqrt(double(num)); if (num == 1) n = 0; else { n = 1; for (i = 3; i < t; i += 2) { if(num % i == 0) n += 2; } if (t * t == num) n ++; } return n; } int main() { int t, no, num; cin >> t; while(t --) { cin >> no >> num; while(num % 2 == 0) { num /= 2; } cout << no << " " << res(num) << 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