結果
問題 |
No.505 カードの数式2
|
ユーザー |
|
提出日時 | 2017-06-22 11:43:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 396 bytes |
コンパイル時間 | 410 ms |
コンパイル使用メモリ | 53,912 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-02 12:11:11 |
合計ジャッジ時間 | 1,323 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 18 |
ソースコード
#include<iostream> using namespace std; int abs(int x){ if(x < 0){ return -1*x; }else{ return x; } } int main(){ int n,m,ans; cin >> n; cin >> ans; for(int i=1;i<n;i++){ cin >> m; m = abs(m); if(m == 1){ ans++; }else if(m != 0){ if(ans != 0 && ans != 1){ ans *= m; }else{ ans += m; } } } cout << ans << endl; }