結果
| 問題 |
No.2323 Nafmo、A+Bをする
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-15 03:03:36 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 414 bytes |
| コンパイル時間 | 305 ms |
| コンパイル使用メモリ | 31,872 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-16 11:45:09 |
| 合計ジャッジ時間 | 3,376 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 17 |
コンパイルメッセージ
main.c: In function 'main':
main.c:18:39: warning: iteration 32 invokes undefined behavior [-Waggressive-loop-optimizations]
18 | ans += pow(2, i) * res[i];
| ~~~^~~
main.c:17:27: note: within this loop
17 | for (int i = 0; i < sizeof(res); i++) {
| ~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdint.h>
#include <math.h>
int main() {
unsigned long a, b, ans;
unsigned long res[32];
scanf("%lu %lu", a, b);
for (int i = 1; i < 32; i++) {
res[i-1] = (a+b) % (unsigned int)pow(10, i) / (unsigned int)pow(10, i-1);
if (res[i-1] == 2) {
res[i-1] = 0;
}
}
for (int i = 0; i < sizeof(res); i++) {
ans += pow(2, i) * res[i];
}
printf("%d\n", ans);
return 0;
}