結果

問題 No.49 算数の宿題
コンテスト
ユーザー togari_takamoto
提出日時 2016-02-28 13:04:13
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 706µs
コード長 244 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,634 ms
コンパイル使用メモリ 176,068 KB
実行使用メモリ 9,908 KB
最終ジャッジ日時 2026-10-15 14:07:15
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:3:26: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
    3 |         char s[102]; gets(s);
      |                      ~~~~^~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/cstdio:47,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/ext/string_conversions.h:47,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/basic_string.h:4442,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/string:56,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bitset:54,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
/usr/include/stdio.h:667:14: note: declared here
  667 | extern char *gets (char *__s) __wur __attribute_deprecated__;
      |              ^~~~
/usr/bin/ld: /tmp/ccNyur6r.o: in function `main':
main.cpp:(.text.startup+0x14): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
int main() {
	char s[102]; gets(s);
	char* i;
	int sum = strtol(s, &i, 10);
	while (*i!='\0') {
		sum = *i == '*' ? sum + strtol(i + 1, &i, 10)
		                : sum * strtol(i + 1, &i, 10);
	}
	printf("%d\n", sum);
}
0