結果

問題 No.222 引き算と足し算
ユーザー sekiya9311sekiya9311
提出日時 2016-06-02 16:16:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,558 bytes
コンパイル時間 878 ms
コンパイル使用メモリ 102,296 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 17:53:38
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 WA -
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 WA -
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 WA -
testcase_24 AC 2 ms
6,944 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
6,940 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
6,940 KB
testcase_31 WA -
testcase_32 AC 2 ms
6,944 KB
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:77:9: warning: 'ff' may be used uninitialized [-Wmaybe-uninitialized]
   77 |         if(ff) cout<<a+b<<endl;
      |         ^~
main.cpp:54:14: note: 'ff' was declared here
   54 |         bool ff;
      |              ^~

ソースコード

diff #

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

class myclass{
public:
    void func(){}
};

int main(void){
	string s; cin>>s;
	int a=0,b=0;
	int e=0;
	bool pf=true;
	bool ff;
	REP(i,s.size()){
		if(i==0&&s[i]=='-') pf=false;
		else if(i!=0&&(s[i]=='+'||s[i]=='-')){
			if(!pf) a*=(-1);
			e=i; break;
		}else{
			a*=10;
			a+=(int)(s[i]-'0');
		}
	}
	if(s[e]=='-') ff=true;
	else if(s[e]=='+')ff=false;
	pf=true;
	FOR(i,e+1,s.size()){
		if(i==e+1&&s[i]=='-') pf=false;
		else{
			b*=10;
			b+=(int)(s[i]-'0');
		}
	}
	if(!pf) b*=-1;
	//DEBUG(a)DEBUG(b)
	if(ff) cout<<a+b<<endl;
	else cout<<a-b<<endl;
}
0