結果
| 問題 |
No.2479 Sum of Squares
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-09-23 00:59:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 745 bytes |
| コンパイル時間 | 324 ms |
| コンパイル使用メモリ | 41,416 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-16 01:24:31 |
| 合計ジャッジ時間 | 1,375 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2479.cc: No.2479 Sum of Squares - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 15;
/* typedef */
typedef long long ll;
/* global variables */
ll as[MAX_N];
/* subroutines */
inline int sqrti(ll s) {
int t0 = 0, t1 = 1000000000 + 1;
while (t0 + 1 < t1) {
int t = (t0 + t1) / 2;
if ((ll)t * t > s) t1 = t;
else t0 = t;
}
return t0;
}
/* main */
int main() {
ll s;
scanf("%lld\n", &s);
int n = 0;
while (s > 0) {
int t = sqrti(s);
ll tt = (ll)t * t;
as[n++] = tt;
s -= tt;
}
printf("%d\n", n);
for (int i = 0; i < n; i++)
printf("%lld%c", as[i], (i + 1 < n) ? ' ' : '\n');
return 0;
}
tnakao0123