【P98】zhxzhx?zhxzhx!
来源:互联网 发布:网面白鞋怎么清洗知乎 编辑:程序博客网 时间:2024/06/07 19:34
emmmm
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;#define LL long longLL n,ans = 0,now = 0;//=A= c++从入门到入土 //QAQ 默默写份题解//qwq 看不懂的地方我们私聊呀~~~~~~~~~ /* 对于(a * b)| x 即 x % ab == 0 设x / ab == c 即 x == abc 设a <= b <= c 则a <= (三次根下n)^ 2 //打不出来数学符号QAQ 这样答案数为 满足 abc <= n 的方案数 */ LL read(){//不讲手读不讲手读 char ch = getchar(); LL x = 0,f = 1; while(!('0' <= ch && ch <= '9')){if(ch == '-') f = -1; ch = getchar();} while('0' <= ch && ch <= '9') {x = (x << 3) + (x << 1) + (ch - '0'); ch = getchar();} return x * f;}// a * b * c == x a != b != c ; a = c b = c ; a = b = c// i * i * i <= n i * i <= n / i//也就是 a * a * a <= n b * b <= n / a int main(){ freopen("a.in","r",stdin); freopen("a.out","w",stdout); n = read();now = 0; for(LL i = 1; (i * i) <= n; i ++){ now += n / (i * i);//a == b LL s = n / i; /* i * i <= n / i -> i * i * i <= n 即当前a == b == c == i 合法 */ if(i * i <= s) ans ++,now --;//a == b == c }//重复情况 ans += now * 3,now = 0; for(LL i = 1; (i * i) <= (n / i); i ++){ LL s = n / i; // cout << "i " << i << " s " << s << endl; for(LL j = i + 1; (j * j) <= s; j ++) now += n / (i * j) - j; //a b c互不相等 //i就是a j就是b 必有j < c 所以c的取值不能包含<=j的部分 }//排列 a != b != c 3! = 6 ans += 6 * now; now = 0; //QAQ printf("%I64d\n",ans); fclose(stdin);fclose(stdout); return 0;}
阅读全文
0 0
- 【P98】zhxzhx?zhxzhx!
- P98
- 【10.30 P98】
- zhx P98 a题
- P87~P98的学习记录
- W. :计数排序.8-2,P98
- 计数排序 (算法导论 p98)
- UVA 12108(p98)----Extraordinary Tired Students
- jq代码学习8--事件绑定 fl ch4 p98
- 《算法导论》CLRS算法C++实现(五)P98 计数排序
- 【DFS序+树状数组】51Nod 1681 公共祖先
- 随机算法(下)
- Referenced file contains errors
- LeetCode 139. Word Break
- c++用递归法将一个整数n转换成字符串
- 【P98】zhxzhx?zhxzhx!
- 第四课:Socket
- 安装使用PhantomJS
- PHP 重定向与延迟重定向
- 我说设计模式
- 2017-10-30离线赛总结
- 二叉树的最大深度
- 人生的选择
- Java 封装类型装箱拆箱常见问题