結果

問題 No.2480 Sequence Sum
ユーザー otamay6otamay6
提出日時 2023-09-22 22:10:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 908 bytes
コンパイル時間 3,082 ms
コンパイル使用メモリ 198,136 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 22:10:31
合計ジャッジ時間 3,825 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    // j*i + k*(i+1) = Nであるi,j,k > 0の組
    // (N-ji)/(i+1)が正整数であるi,jの組
    // あるiに対してj ≡ -N (mod i+1)である0 < j < N/iの数
    int n; cin>>n;
    ll res = 0;
    rep(i, 1, sqrt(n)+1){
        ll mod_j = ((i+1) - n % (i+1)) % (i+1);
        ll j_max = (n-1)/i;
        // t * (i+1) + mod_j <= j_max
        if(j_max >= mod_j) {
            ll t_max = (j_max - mod_j) / (i+1);
            // std::cerr << i << " " << mod_j << " " << j_max  << " " << t_max << endl;
            res += t_max;
            if(mod_j){
                res += 1;
            }
        }
    }
    cout << res << endl;
}
0