【P98】zhxzhx?zhxzhx!

這裏寫圖片描述

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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章