結果
問題 | No.1081 和の和 |
ユーザー |
![]() |
提出日時 | 2020-06-23 16:15:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,218 bytes |
コンパイル時間 | 1,596 ms |
コンパイル使用メモリ | 167,148 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 19:20:18 |
合計ジャッジ時間 | 1,870 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, n) for (int i = 0; i < (int)(n); i++)#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)#define ll long long#define umap unordered_mapusing graph = vector<vector<int>>;using graph2 = vector<vector<pair<int, int>>>;#define oorret true //std::out_of_rangeが返された時#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()double pi = 3.141592653589793238;ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minusll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd downll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd upll M=1e9+7;int quick_pow(int x,int p){int a=1,po=x;while(p){if(p&1) a=1ll*a*po%M;po=1ll*po*po%M;p>>=1;}return a;}int nCr(int n, int r){r=min(r, n-r);ll a=1, b=1;rep(i, r){a*=n-i;a%=M;}rep2(i, r){b*=i;b%=M;}b=quick_pow(b, M-2);a*=b;a%=M;return a;}int main(){int N;cin>>N;ll A[N];rep(i, N){cin>>A[i];}ll sum=0;rep(i, N){sum+=nCr(N-1, i)*A[i];sum%=M;}cout<<sum<<endl;}