博客
关于我
LightOJ 1336 Sigma Function
阅读量:791 次
发布时间:2023-01-31

本文共 2020 字,大约阅读时间需要 6 分钟。

/* LightOJ 1336    Sigma Function http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1336数论 奇偶性题目求f(n)为偶数的个数我们发现如果f(n)为奇数,则n为x^2,2*x^2,2^x三种形式,因为2^x中已经包含剩下两种,所以只需求x^2和2*x^2的个数即可求得答案。 * 打了半天表发现没用233333 * */#include 
#include
using namespace std;int main(){ //freopen("a.in","r",stdin); int t; scanf("%d",&t); long long n; int j=1; while(t--) { scanf("%lld",&n); long long ans=0; for(long long i=1;i*i<=n;i++) { if(2*i*i<=n) ans++; ans++; } ans=n-ans; printf("Case %d: %lld\n",j,ans); j++; } return 0;}//打表/*#include
*///#include
//using namespace std;//const int Nmax=10001;//int prime[Nmax];//int is_prime[Nmax];//int cnt;//int m[Nmax];//int times[Nmax];//int num;//void get_prime()//{ //for(int i=2;i
0) //{ //if(n&1) //ans*=base; //base*=base; //n>>=1; //} //return ans;//}//int check()//{ //for(int i=1;i<=num;i++) //{ //int a=pow(m[i],times[i]+1)-1; //int b=m[i]-1; //a/=b; //if(!(a&1)) //return 1; //} //return 0;//}//void get(int n)//{ //num=0; //int i=1; //while(prime[i]*prime[i]<=n) //{ //if(n%prime[i]==0) //{ //++num; //times[num]=0; //m[num]=prime[i]; //} //while(n%prime[i]==0) //{ //n/=prime[i]; //times[num]++; //} //i++; //} //if(n!=1) //{ //++num; //times[num]=1; //m[num]=n; //}//}//void print(int n)//{ //int ans=0; //for(int i=2;i<=n;i++) //{ //get(i); //ans+=check(); //} //printf("%d:%d\n",n,ans);//}//int main()//{ //get_prime(); //for(int n=1;n<=1000;n++) //{ //print(n); //} //return 0;/*}*/

 

转载于:https://www.cnblogs.com/BBBob/p/6526728.html

你可能感兴趣的文章
leetcode Plus One
查看>>
LeetCode shell 题解(全)
查看>>
LeetCode Text Justification
查看>>
leetcode Valid Parentheses
查看>>
Leetcode | Simplify Path
查看>>
LeetCode – Refresh – 4sum
查看>>
LeetCode – Refresh – Valid Number
查看>>
LeetCode 中级 - 有序链表转换二叉搜索树(109)
查看>>
leetCode 字符串反转
查看>>
LeetCode 无重复字符的最长子串 获取字符串中不重复的子串最大长度
查看>>
leetCode 给定数组,目标值 计算数组下标
查看>>
leetcode 验证回文字符串 java实现
查看>>
LeetCode(229):Majority Element ||
查看>>
leetcode--
查看>>
LeetCode--020--括号匹配
查看>>
Leetcode-966 Vowel Spellchecker(元音拼写检查器)
查看>>
LeetCode-Binary Tree Maximum Path Sum
查看>>
LeetCode111.二叉树最小深度
查看>>
LeetCode136.只出现一次的数字[异或运算典例]
查看>>
LeetCode13:罗马数字转整数
查看>>