結果
| 問題 |
No.2086 A+B問題
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2022-09-30 21:29:45 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 860 bytes |
| コンパイル時間 | 1,138 ms |
| コンパイル使用メモリ | 30,592 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-22 22:25:15 |
| 合計ジャッジ時間 | 968 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <stdio.h>
int main () {
char a[102] = "";
char b[102] = "";
int res = 0;
int lena = 0;
int lenb = 0;
int lenans = 0;
char ans[102] = "";
int c = 0;
res = scanf("%s", a);
res = scanf("%s", b);
while (a[lena] != '\0') {
lena++;
}
while (b[lenb] != '\0') {
lenb++;
}
while (lena > 0 || lenb > 0) {
int tmp = c;
if (lena > 0) {
lena--;
tmp += (int) (a[lena]-'0');
}
if (lenb > 0) {
lenb--;
tmp += (int) (b[lenb]-'0');
}
c = tmp/10;
ans[lenans] = ((char)(tmp%10))+'0';
lenans++;
}
if (c > 0) {
ans[lenans] = ((char)c)+'0';
lenans++;
}
ans[lenans] = '\0';
for (int i = 0; i < lenans/2; i++) {
char tmp = ans[i];
ans[i] = ans[lenans-i-1];
ans[lenans-i-1] = tmp;
}
printf("%s\n", ans);
return 0;
}
chro_96