結果
| 問題 | 
                            No.49 算数の宿題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             srup٩(๑`н´๑)۶
                         | 
                    
| 提出日時 | 2016-07-20 20:25:33 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                CE
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,095 bytes | 
| コンパイル時間 | 429 ms | 
| コンパイル使用メモリ | 52,768 KB | 
| 最終ジャッジ日時 | 2024-11-15 04:44:23 | 
| 合計ジャッジ時間 | 862 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:75: error: ‘pow’ was not declared in this scope; did you mean ‘now’?
   20 |                                                 now += (s[i] - '0')     * pow(10, cnt);
      |                                                                           ^~~
      |                                                                           now
main.cpp:25:75: error: ‘pow’ was not declared in this scope; did you mean ‘now’?
   25 |                                                 now += (s[i] - '0')     * pow(10, cnt + 1);
      |                                                                           ^~~
      |                                                                           now
main.cpp:37:75: error: ‘pow’ was not declared in this scope; did you mean ‘now’?
   37 |                                                 now += (s[i] - '0')     * pow(10, cnt);
      |                                                                           ^~~
      |                                                                           now
main.cpp:42:75: error: ‘pow’ was not declared in this scope; did you mean ‘now’?
   42 |                                                 now += (s[i] - '0')     * pow(10, cnt + 1);
      |                                                                           ^~~
      |                                                                           now
            
            ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
int main(void){
	string s; cin >> s;
	long long ans = 0;
	int memo = 0;//0 = (*) 1 = (+)
	for (int l = 0; l < s.size(); ++l){
		double cnt = -1;
		int now = 0;
		int r;
		for (r = l; r < s.size(); ++r){
			if(s[r] == '*' || r == s.size() - 1){
				if(r != s.size() - 1){
					for (int i = l; i < r; ++i){
						now += (s[i] - '0')	* pow(10, cnt);
						cnt--;
					}
				}else{
					for (int i = l; i <= r; ++i){
						now += (s[i] - '0')	* pow(10, cnt + 1);
						cnt--;
					}
				}
				if(memo == 0) ans += now;
				else ans *= now;
				memo = 0;
				break;
			}else if(s[r] == '+' || r == s.size() - 1){
				if(r != s.size() - 1){
					for (int i = l; i < r; ++i){
						now += (s[i] - '0')	* pow(10, cnt);
						cnt--;
					}
				}else{
					for (int i = l; i <= r; ++i){
						now += (s[i] - '0')	* pow(10, cnt + 1);
						cnt--;
					}
				}
				if(memo == 0) ans += now;
				else ans *= now;
				memo = 1;
				break;
			}
			cnt++;	
		}
		l = r;
	}
	printf("%lld\n", ans);
	return 0;
}
            
            
            
        
            
srup٩(๑`н´๑)۶