結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2015-06-20 22:28:19 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 828 bytes |
コンパイル時間 | 1,378 ms |
コンパイル使用メモリ | 159,960 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 01:45:50 |
合計ジャッジ時間 | 1,710 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h>int main() {long ans;std::string tstr;char str[128];long p = 0;long N;long temp;char ope;std::cin >> tstr;strcpy( str, tstr.c_str() );N = tstr.size();p = 0;temp = 0;for(int i = p; i < N; ++i) {if( not ( '0' <= str[i] and str[i] <= '9' ) ) {p = i;break;}temp *= 10;temp += str[i] - '0';}ans = temp;for(;;) {if( p >= N ) { break; }ope = str[p];p += 1;temp = 0;for(int i = p; i < N; ++i) {if( not ( '0' <= str[i] and str[i] <= '9' ) ) {p = i;break;}temp *= 10;temp += str[i] - '0';}switch( ope ) {case '+':ans *= temp;break;case '*':ans += temp;break;}}std::cout << ans << std::endl;return 0;}