Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

本方法改进0MS 不需公式(附码)

Posted by 307250217 at 2010-02-21 16:31:19 on Problem 2853
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator