結果

問題 No.8072 Sum of sqrt(x)
ユーザー 259_Momone
提出日時 2020-09-12 23:26:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,369 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 2,962 ms
コンパイル使用メモリ 194,472 KB
最終ジャッジ日時 2025-01-14 14:02:24
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%lu", &N);
      |     ~~~~~^~~~~~~~~~~
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%lu", &t);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    scanf("%lu", &N);
    vector<long double> v(N + 1);
    for(unsigned long i{1}, t; i <= N; ++i){
        scanf("%lu", &t);
        v[i] = sqrtl(t);
    }
    for(unsigned long i{1}; i <= N; i <<= 1UL)for(unsigned long j{2 * i}; j <= N; j += 2 * i)v[j] += v[j - i];
    for(unsigned long i{1}; i <= N; ++i)printf("%.18Lg\n", v[i] += v[i & (i - 1)]);
    return 0;
}
0