【P98】zhxzhx?zhxzhx!

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Loi_Shirley/article/details/78396578

这里写图片描述

emmmm

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define LL long long
LL 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;
}
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页