LightOJ1336 Sigma Function 素因子分解深入理解

  1. 只有奇数乘奇数才是奇数,而如果使式子为奇数,只能是2的所有次数或者其他素数的偶数次。
  2. 素数的次数的任意组合小于等于n的个数有n个,因为每一个数都可以素因子分解成不同的组合。
  3. 所以奇数有两类,a^2 <= n,或者2是奇数次,2*a^2 <= n,而a就是符合情况的所有组合。

题目链接:http://acm.hust.edu.cn/vjudge/problem/27044

#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<vector>
#include<fstream>
#include<list>
using namespace std;

#define ms(s) memset(s,0,sizeof(s))
typedef unsigned long long ULL;
typedef long long LL;

const int INF = 0x3fffffff;

LL n,ans;

int main()
{
//    freopen("F:\\input.txt","r",stdin);
//    freopen("F:\\output.txt","w",stdout);
//    ios::sync_with_stdio(false);

    int t;
    scanf("%d",&t);
    for(int cas = 1; cas <= t; ++cas){
        scanf("%lld",&n);
        ans = n - (LL)sqrt(n) - (LL)sqrt(n/2);
        printf("Case %d: %lld\n",cas,ans);
    }
    return 0;
}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值