• Sigma Function (平方数与平方数*2的约数和是奇数)


    Sigma Function

    https://vjudge.net/contest/288520#problem/D

    Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4+6+8+12+24=60. Sigma of small numbers is easy to find but for large numbers it is very difficult to find in a straight forward way. But mathematicians have discovered a formula to find sigma. If the prime power decomposition of an integer is

    Then we can write,

    For some n the value of σ(n) is odd and for others it is even. Given a value n, you will have to find how many integers from 1 to n have even value of σ.

    Input

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

    Each case starts with a line containing an integer n (1 ≤ n ≤ 1012).

    Output

    For each case, print the case number and the result.

    Sample Input

    4

    3

    10

    100

    1000

    Sample Output

    Case 1: 1

    Case 2: 5

    Case 3: 83

    Case 4: 947

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define lson l,mid,rt<<1
     4 #define rson mid+1,r,rt<<1|1
     5 #define sqr(x) ((x)*(x))
     6 #define pb push_back
     7 #define eb emplace_back
     8 #define maxn 100005
     9 #define eps 1e-8
    10 #define pi acos(-1.0)
    11 #define rep(k,i,j) for(int k=i;k<j;k++)
    12 typedef long long ll;
    13 typedef pair<int,int> pii;
    14 typedef pair<long long,int>pli;
    15 typedef pair<int,char> pic;
    16 typedef pair<pair<int,string>,pii> ppp;
    17 typedef unsigned long long ull;
    18 const long long mod=998244353;
    19 /*#ifndef ONLINE_JUDGE
    20         freopen("1.txt","r",stdin);
    21 #endif */
    22 
    23 int pow_mul(ll a,ll b){
    24     int ans=1;
    25     while(b){
    26         if(b&1) ans=ans*a%1000;
    27         b>>=1;
    28         a=a*a%1000;
    29     }
    30     return ans;
    31 }
    32 
    33 int main(){
    34     #ifndef ONLINE_JUDGE
    35      //   freopen("1.txt","r",stdin);
    36     #endif
    37   //  std::ios::sync_with_stdio(false);
    38     int t;
    39     cin>>t;
    40     for(int _=1;_<=t;_++){
    41         ll n;
    42         cin>>n;
    43         int ans=0;
    44         for(ll i=1;i*i<=n;i++){
    45             ans++;
    46             if(i*i*2<=n) ans++;
    47         }    
    48         cout<<"Case "<<_<<": "<<n-ans<<endl;
    49     }
    50 }
    View Code
  • 相关阅读:
    [整理]Cadence 生成带有网络追踪的 PDF 原理图
    [整理]FSM 有限状态机
    [原创]Quartus 中调用 Modelsim 波形仿真
    [原创]SPI 协议介绍以及基于 Verilog 的 IP 核实现
    [原创]Verilog 代码编程规范(个人用)
    [算法]线段树
    [算法]tarjan
    poj3280
    poj 3258 River Hopscotch
    [poj 1251]Jungle Roads
  • 原文地址:https://www.cnblogs.com/Fighting-sh/p/10551347.html
Copyright © 2020-2023  润新知