結果

問題 No.781 円周上の格子点の数え上げ
ユーザー treeonetreeone
提出日時 2019-01-11 22:25:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,430 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 199,100 KB
実行使用メモリ 97,872 KB
最終ジャッジ日時 2023-08-20 07:53:33
合計ジャッジ時間 19,055 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 665 ms
97,556 KB
testcase_01 WA -
testcase_02 AC 683 ms
97,516 KB
testcase_03 WA -
testcase_04 AC 640 ms
97,544 KB
testcase_05 AC 768 ms
97,580 KB
testcase_06 WA -
testcase_07 AC 654 ms
97,540 KB
testcase_08 WA -
testcase_09 AC 640 ms
97,540 KB
testcase_10 AC 643 ms
97,692 KB
testcase_11 AC 648 ms
97,692 KB
testcase_12 AC 1,003 ms
97,632 KB
testcase_13 AC 1,276 ms
97,608 KB
testcase_14 AC 654 ms
97,580 KB
testcase_15 WA -
testcase_16 AC 652 ms
97,644 KB
testcase_17 AC 1,007 ms
97,712 KB
testcase_18 AC 653 ms
97,792 KB
testcase_19 AC 640 ms
97,752 KB
testcase_20 AC 645 ms
97,596 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(n % 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