Submission #9437366


Source Code Expand

Copy
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
    template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    int a[N],b[N];
    void main()
	{
        int n=qread();fo(i,1,n) a[i]=qread();fd(i,n,2) a[i]-=a[i-1];
        fo(i,1,n) b[i]=mm(b[i-1]+invm(i));
        ll ans=0;fo(i,2,n) add(ans, 1ll*a[i]*b[i-1]%MOD );
        fo(i,1,n-1) ans=ans*i%MOD;write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}

Submission Info

Submission Time
Task B - Fusing Slimes
User Zory
Language C++14 (GCC 5.4.1)
Score 600
Code Size 2029 Byte
Status
Exec Time 26 ms
Memory 1024 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02
Subtask 400 / 400 small_01, small_02, small_03, small_04, small_05, small_06, small_07, small_08, small_09, small_10, small_max_01, small_max_02, small_max_03, small_max_04, small_max_05
All 200 / 200 max_01, max_02, max_03, max_04, max_05, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, sample_01, sample_02, small_01, small_02, small_03, small_04, small_05, small_06, small_07, small_08, small_09, small_10, small_max_01, small_max_02, small_max_03, small_max_04, small_max_05
Case Name Status Exec Time Memory
max_01 26 ms 1024 KB
max_02 25 ms 1024 KB
max_03 25 ms 1024 KB
max_04 25 ms 1024 KB
max_05 25 ms 1024 KB
random_01 7 ms 384 KB
random_02 23 ms 1024 KB
random_03 14 ms 640 KB
random_04 11 ms 640 KB
random_05 2 ms 256 KB
random_06 13 ms 640 KB
random_07 4 ms 384 KB
random_08 10 ms 512 KB
random_09 17 ms 768 KB
random_10 11 ms 512 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
small_01 2 ms 256 KB
small_02 2 ms 256 KB
small_03 2 ms 256 KB
small_04 2 ms 256 KB
small_05 1 ms 256 KB
small_06 2 ms 256 KB
small_07 2 ms 256 KB
small_08 2 ms 256 KB
small_09 1 ms 256 KB
small_10 1 ms 256 KB
small_max_01 2 ms 256 KB
small_max_02 2 ms 256 KB
small_max_03 2 ms 256 KB
small_max_04 2 ms 256 KB
small_max_05 2 ms 256 KB