Light Oj 1098 A New Function 因子和
来源:互联网 发布:alias软件快捷键作用 编辑:程序博客网 时间:2024/06/06 03:35
http://www.lightoj.com/volume_showproblem.php?problem=1098
枚举 1 到 sqrt(n),我们知道 所有 有相同因子 a,他们相对于 a 的另外一个因子 应该成为一个等差数列。
例如: 2 ,4, 6, 8.。。。对于 因子 2 ,对应的因子分别为1,2,3,4,。
枚举每一个因子,把该因子出现的次数统计出来,对应因子出现 的序列求出来即可。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;typedef __int64 LL;int main(){ LL T,tt=0; cin>>T; LL n; while(T--) { cin>>n; LL i,j,k,m,ans=0,p,q,d; m=(LL)sqrt(n+0.5); for(i=2;i<=m;i++) { ans+=i; p=i+1; q=n/i; if(q<p)continue; ans+=(q-p+1)*i;//因子 i 出现的所有和 ans+=(p+q)*(q-p+1)/2;// 因子 i 对应因子出现的所有和 } cout<<"Case "<<++tt<<": "<<ans<<endl; } return 0;}
0 0
- Light Oj 1098 A New Function 因子和
- lightoj 1098 - A New Function 因子和
- Light OJ 1336 Sigma Function(因子和)
- LIGHT OJ 1109 - False Ordering 【因子个数】
- Sigma Function (因子和)
- 关于function,new function 和 new Function
- Light OJ 1028 Trailing Zeroes (I) 求n因子数
- Light OJ 1014 Ifter Party [因子分解]【数论】
- LIGHT OJ 1278 Sum of Consecutive Integers [因子个数]【数论】
- Light OJ:1141 Number Transformation(BFS+素因子)
- 详解new function(){}和function(){}()
- 详解new function(){}和function(){}()
- 详解new function(){}和function(){}()
- Light OJ 1036A Refining Company (DP)
- Light OJ 1006 Hex-a-bonacci
- Light OJ 1277 Looking for a Subsequence
- Light OJ 1201 - A Perfect Murder
- light oj 1020 - A Childhood Game (博弈)
- 360应用市场jQuery幻灯片
- 三个技师
- hgl
- 发布到iis后,文字显示出现问题
- Linux中select函数
- Light Oj 1098 A New Function 因子和
- PV原语
- git学习-warning:LF will be replaced by CRLF
- Objective-C中的Block
- 百度搜录的依据和百度蜘蛛对方分析结果发图突然俗套人总是的态度
- cocos2d-x的TestCpp分析
- C 语言宏定义的几个技巧
- ANDROID开发之SQLite详解
- linux下gdb单步调试 .