結果

問題 No.1334 Multiply or Add
ユーザー PCTprobability
提出日時 2021-01-08 21:51:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,263 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 168,788 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-16 11:11:30
合計ジャッジ時間 4,289 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
//const ll mod = 998244353;
const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll n;
  cin>>n;
  vector<ll> a(n);
  vcin(a);
  vector<ll> s;
  ll tmp=1;
  ll ans=0;
  for(int i=0;i<n;i++){
    if(a[i]==1){
      ans++;
      if(tmp!=1){
        ans+=tmp;
      }
      ans%=mod;
    }
    else{
      tmp*=a[i];
      tmp%=mod;
    }
  }
  if(tmp!=1){
    ans+=tmp;
    ans%=mod;
  }
  ans%=mod;
  cout<<ans<<endl;
}
0