結果

問題 No.8072 Sum of sqrt(x)
ユーザー 259_Momone
提出日時 2020-09-12 23:22:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 453 bytes
コンパイル時間 2,941 ms
コンパイル使用メモリ 194,988 KB
最終ジャッジ日時 2025-01-14 14:01:08
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2 RE * 1
other WA * 8 RE * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:55: warning: use of ‘ll’ length modifier with ‘g’ type character has either no effect or undefined behavior [-Wformat=]
   13 |     for(unsigned long i{1}; i <= N; ++i)printf("%.18llg\n", v[i] += v[i & (i - 1)]);
      |                                                       ^
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", &N);
      |         ~~~~~^~~~~~~~~~~
main.cpp:10:21: warning: ‘t’ may be used uninitialized [-Wmaybe-uninitialized]
   10 |         v[i] = sqrtl(t);
      |                ~~~~~^~~
main.cpp:8:29: note: ‘t’ was declared here
    8 |     for(unsigned long i{1}, t; i <= N; ++i){
      |                             ^

ソースコード

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", &N);
        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("%.18llg\n", v[i] += v[i & (i - 1)]);
    return 0;
}
0