NEUOJ 1403: XL's Math Problem II
来源:互联网 发布:采购数据分析 编辑:程序博客网 时间:2024/04/28 16:07
题目如图所示,由于n很大直接枚举肯定不行,所以以此枚举商x,把最左边的i和最右边的j使得满足n/i=x,n/j=x,的i,和j求出来,j-i+1就是商x的个数。
顺便说一句感谢朱神。哈哈
#include<cstring>#include<cstdio>#include<algorithm>using namespace std;typedef long long LL;int main(){ int n,cas,L,R,cnt=0; LL ans; scanf("%d",&cas); while(cas--) { scanf("%d",&n); L=R=1; ans=0; int cur=1; while(L<=n) { int ret=n/cur; R=n/ret; if(R>=n) R=n; ans+=(R-L+1)*ret; L=R+1; cur=L; } printf("Case%d: %lld\n",++cnt,ans); } return 0;}
1 0
- NEUOJ 1403: XL's Math Problem II
- HDU5170GTY's math problem
- Jam's math problem
- hdu5615Jam's math problem
- HDU5615Jam's math problem
- Jam's math problem
- HDU5170 GTY's math problem
- HDU5170 GTY's math problem
- HDU5615:Jam's math problem
- hdu5616 Jam's math problem
- tju3772. Rupxup's Math Problem
- Jam's math problem<hdoj5615>
- I - Jam's math problem
- HDU5615 Jam's math problem
- TOJ3772 Rupxup's Math Problem
- NEUOJ 1262: ASCII Sequence II
- 【BestCoder】 HDOJ 5170 GTY's math problem
- HDU 5170 GTY's math problem
- MyEclipse10中文注释太小
- List,数组,map,set 相互转化
- Niblack算法和OTSU算法的实现
- Hibernate4获取session
- 浅谈响应式布局
- NEUOJ 1403: XL's Math Problem II
- js的面向对象
- final与static的区别
- videolectures 100个最受欢迎的机器学习视频
- linux 查找命令
- 虚拟机 Centos 共享 WIN7 文件
- zoj 3715
- 丑小鸭进化 之 UML入门篇(二)
- pig flatten