【題解】AtCoder ABC 190D – Staircase Sequences

【題目敘述】https://atcoder.jp/contests/abc190/tasks/abc190_d

#include <bits/stdc++.h>
using namespace std;

long long n;
int ans;

int main(){
    cin >> n;
    for (int i = 1; i <= sqrt(n); i++){
        if (n%i != 0) continue;
        long long j = n/i;
        if (i%2 == 0 && j%2 == 0) continue;
        if (i%2 == 1 && j%2 == 1 && i != j) ans += 4;
        else ans += 2;
    }
    cout << ans << "\n";
}

分享本文 Share with friends