結果
問題 | No.2479 Sum of Squares |
ユーザー |
|
提出日時 | 2023-09-30 15:15:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 461 ms / 2,000 ms |
コード長 | 445 bytes |
コンパイル時間 | 2,728 ms |
コンパイル使用メモリ | 247,816 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 09:15:16 |
合計ジャッジ時間 | 6,594 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:17:10: warning: 'num' may be used uninitialized [-Wmaybe-uninitialized] 17 | S-=num; | ~^~~~~ main.cpp:12:19: note: 'num' was declared here 12 | long long num; | ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { long long S; cin >> S; vector<long long> ans; while(1){ if(S==0){ break; } long long num; for(long long i=1;i*i<=S;i++){ num=i*i; } ans.push_back(num); S-=num; } cout << ans.size() << endl; for(int i=0;i<ans.size();i++){ cout << ans[i] << " "; } cout << endl; }