lightoj 1028 xjb组合

We know what a base of a number is and what the properties are. For example, we use decimal number system, where the base is 10 and we use the symbols - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. But in different bases we use different symbols. For example in binary number system we use only 0 and 1. Now in this problem, you are given an integer. You can convert it to any base you want to. But the condition is that if you convert it to any base then the number in that base should have at least one trailing zero that means a zero at the end.

For example, in decimal number system 2 doesn’t have any trailing zero. But if we convert it to binary then 2 becomes (10)2 and it contains a trailing zero. Now you are given this task. You have to find the number of bases where the given number contains at least one trailing zero. You can use any base from two to infinite.

Input
Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each case contains an integer N (1 ≤ N ≤ 1012).

Output
For each case, print the case number and the number of possible bases where N contains at least one trailing zero.

Sample Input
Output for Sample Input
3
9
5
2
Case 1: 2
Case 2: 1
Case 3: 1

就是求一个数的所有约数….
很弱智
但是坑了我一天
我比这个题更弱智

#include<iostream>
#include<cmath>
#include<cstdio>
#include<memory.h>
using namespace std;
long long n,jishu;
long long tu[1000011];
long long sushu[1000011];
int main()
{
    //tu[0] = tu[1] = 1;
    long long gr = 0;
    for (long long a = 2;a<= 1000010;a++)//注意这个要记录素数不能a*a<=1000000因为...后面没得记录
        //测试数据太小了坑了我一天...玛德气哭
    {
        if (tu[a])continue;
        sushu[++gr] = a;
        for (long long b = a*a;b <= 1000010;b+=a)tu[b] = 1;
    }
    long long  T;
    cin >> T;
    long long u = 0;
    while (T--)
    {
        scanf("%lld", &n);
        jishu = 1;
        long long ss = n;
        for (long long a = 1;a <= gr&&(sushu[a] * sushu[a]) <= ss;a++)
        {
            long long yyy = 1;
            if (ss%sushu[a])continue;
            while (ss%sushu[a] == 0) { ss /= sushu[a], yyy++; }
            jishu *= yyy;
        }
        if (ss > 1)jishu*=2;
        printf("Case %lld: %lld\n", ++u, jishu-1);
    }
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值