結果
| 問題 | No.8062 A + B |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-30 23:50:48 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 752 bytes |
| 記録 | |
| コンパイル時間 | 3,540 ms |
| コンパイル使用メモリ | 337,584 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-01-30 23:50:53 |
| 合計ジャッジ時間 | 4,741 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(void){
string a,b;
cin>>a>>b;
string s=a+b;
if(b[0]!='-'&&b[0]!='+'){
int f3=0;
for(int i=0;i<a.size();i++){
if(a[i]!='0'&&a[i]!='+')f3++;
if(f3)cout<<a[i];
}
cout<<b<<endl;
return 0;
}
long long a1=0,ans=0;
int f=0,f2=0;
for(int i=0;i<s.size();i++){
if(s[i]=='-'){
ans+=a1*(f==-1?-1:1);
f=-1;
a1=0;
f2++;
}else if(s[i]=='+'){
ans+=a1*(f==-1?-1:1);
a1=0;
f=0;
}else{
a1*=10;
a1+=s[i]-'0';
}
}
ans+=a1*(f==-1?-1:1);
cout <<ans<<endl;
return 0;
}