結果

問題 No.1567 Integer Coefficient Equation
ユーザー もなもな
提出日時 2021-06-26 16:25:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,885 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 204,448 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-07 17:03:25
合計ジャッジ時間 8,977 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define reps(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repit(i,C) for (auto i = (C).begin(); break_flg && (i != (C).end()); i++)
#define repits(i,sitr,C) for (auto i = sitr; break_flg && (i != (C).end()); i++)
#define pr(a) cout << a
#define prl(a) cout << (a) << endl
#define prld(a) cout << setprecision(15)<< (a) << endl 
#define allrange(a) a.begin(),a.end()

/*  divisor(n)
    入力:整数 n
    出力:nのすべての約数
    計算量:O(√n)
*/
vector<int> divisor(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

inline bool check(int d1,int d2,int m)
{
    return (d1!=d2) && (((m/d2-m/d1)%(d1-d2)) == 0);
}

int main(){
    int T;
    cin >> T;
    rep(i,T){
        int p,l,r;
        cin >> p >> l >> r;
        int ct = 0;
        reps(k,l,r+1)
        {
            if(k!=p){
            int M = abs(k-p);
            auto d = divisor(M);
            if(d.size()<5) continue;
            ct++;
        /*
            bool break_flg = true;
            repit(itr1,d)
             repits(itr2,itr1+1,d)
                if(check(*itr2,*itr1,M))  repits(itr3,itr2+1,d)
                    if(check(*itr3,*itr2,M))  repits(itr4,itr3+1,d)
                       if(check(*itr4,*itr3,M))  repits(itr5,itr4+1,d)
                         if(check(*itr5,*itr4,M)) { ct++; break_flg=false; break;}
        */
            }else{
              auto d = divisor(abs(k));
              if(d.size()<=5) continue;
              ct++;                
            }
        }
        prl(ct);
    }


}
0