結果

問題 No.2937 Sigma Plus Problem
ユーザー yuusaan
提出日時 2024-10-09 11:38:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 300 ms
コード長 535 bytes
コンパイル時間 3,217 ms
コンパイル使用メモリ 244,508 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 11:38:26
合計ジャッジ時間 4,312 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ull = unsigned long long;

int INF = 1000000000;

int main(){
    ull N;
    cin >> N;
    ull ans = 0;
    ull br = sqrt(N);//いくつ毎に区切るか
    ull stair = 0;//階段状になっている部分
    for(int i = 1;i <= br;i++)stair += i;
    ull base = 0;//下側の階段状になっていない部分
    for(int i = 0;i < br;i++){
        ans += stair + base;
        base += br * br;
    }
    for(ull i = br * br + 1;i <= N;i++)ans += i;
    cout << ans << endl;
}
0