結果

問題 No.781 円周上の格子点の数え上げ
ユーザー treeonetreeone
提出日時 2019-01-11 22:23:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,432 bytes
コンパイル時間 2,691 ms
コンパイル使用メモリ 199,208 KB
実行使用メモリ 96,676 KB
最終ジャッジ日時 2023-08-20 07:46:57
合計ジャッジ時間 21,016 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 723 ms
96,604 KB
testcase_01 WA -
testcase_02 AC 712 ms
96,428 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 708 ms
96,540 KB
testcase_06 WA -
testcase_07 AC 713 ms
96,604 KB
testcase_08 WA -
testcase_09 AC 749 ms
96,488 KB
testcase_10 AC 724 ms
96,672 KB
testcase_11 AC 722 ms
96,464 KB
testcase_12 AC 1,079 ms
96,672 KB
testcase_13 AC 1,360 ms
96,656 KB
testcase_14 AC 715 ms
96,472 KB
testcase_15 WA -
testcase_16 AC 736 ms
96,424 KB
testcase_17 AC 1,113 ms
96,492 KB
testcase_18 AC 721 ms
96,468 KB
testcase_19 AC 688 ms
96,676 KB
testcase_20 AC 715 ms
96,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;
const int MAX_N = 10000010;
int prime[MAX_N];
bool is_prime[MAX_N + 1];
int pf[MAX_N];
int sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2*i; j <= n; j += i){
                is_prime[j] = false;
                pf[j] = i;
            }
        }
    }
    return p;
}

int prime_factor(int n){
    int res = 1;
    while(n != 1){
        int now = pf[n];
        if(now == 0){
            if(now % 4 == 1) res *= 2;
            else res = 0;
            break;
        }
        int cnt = 0;
        while(n % now == 0){
            n /= now;
            cnt++;
        }
        if(now % 4 == 1) res *= cnt + 1;
        else return 0;
    }
    return res * 4;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    sieve(MAX_N);
    int x, y;
    cin >> x >> y;
    int ans = 0;
    for(int i = x; i <= y; i++){
        ans = max(ans, prime_factor(i));
    }
    cout << ans << endl;
}
0