633. Sum of Square Numbers

Given a non-negative integer `c`, decide whether there're two integers `a` and `b` such that `a2 + b2 = c`.

Example 1:

```Input: c = 5
Output: true
Explanation: 1 * 1 + 2 * 2 = 5
```

Example 2:

```Input: c = 3
Output: false
```

Example 3:

```Input: c = 4
Output: true
```

Example 4:

```Input: c = 2
Output: true
```

Example 5:

```Input: c = 1
Output: true
```

Constraints:

• `0 <= c <= 231 - 1`

633. Sum of Square Numbers
``````struct Solution;

impl Solution {
fn judge_square_sum(c: i32) -> bool {
if c == 0 {
return true;
}
let x = (c as f64).sqrt() as i32;
for a in 0..=x {
let bb = c - a * a;
let b = (bb as f64).sqrt() as i32;
if bb == b * b {
return true;
}
}
false
}
}

#[test]
fn test() {
assert_eq!(Solution::judge_square_sum(5), true);
assert_eq!(Solution::judge_square_sum(3), false);
assert_eq!(Solution::judge_square_sum(2_147_483_646), false);
}
``````
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://rustgym.com/leetcode/633", "fetch_time": 1670166710000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2022-49/segments/1669446710974.36/warc/CC-MAIN-20221204140455-20221204170455-00609.warc.gz", "warc_record_offset": 536156107, "warc_record_length": 2962, "token_count": 319, "char_count": 908, "score": 3.546875, "int_score": 4, "crawl": "CC-MAIN-2022-49", "snapshot_type": "latest", "language": "en", "language_score": 0.6269019246101379, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00011-of-00064.parquet"}