Sigma (化简)牛客多校第一场 -- Integration
思路:
可以裂项化简,类似找规律,可以两项、三项代进去试试看。
1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa system("cls") 4 #include <iostream>//pair 5 #include <fstream> 6 #include <bitset> 7 //#include <map> 8 //#include<unordered_map> 9 #include <vector> 10 #include <stack> 11 #include <set> 12 #include <string.h>//strstr substr 13 #include <string> 14 #include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9; 15 #include <cmath> 16 #include <deque> 17 #include <queue>//priority_queue<long long, vector<long long>, greater<long long> > q;//less 18 #include <vector>//emplace_back 19 //#include <math.h> 20 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor 21 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare) 22 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation 23 #define mem(a,b) memset(a,b,sizeof(a)) 24 #define fo(a,b,c) for(a=b;a<=c;++a)//register long long i 25 #define fr(a,b,c) for(a=b;a>=c;--a) 26 #define pr printf 27 #define sc scanf 28 void swapp(long long &a,long long &b); 29 double fabss(double a); 30 long long maxx(long long a,long long b); 31 long long minn(long long a,long long b); 32 long long Del_bit_1(long long n); 33 long long lowbit(long long n); 34 long long abss(long long a); 35 //const long long INF=(1LL<<60); 36 const double E=2.718281828; 37 const double PI=acos(-1.0); 38 const long long inf=(1<<29); 39 const double ESP=1e-9; 40 const long long mod=(long long)1e9+7; 41 const long long N=(long long)1e6+6; 42 43 long long a[N]; 44 long long qpow(long long a,long long b,long long mod) 45 { 46 long long ans; 47 a%=mod; 48 ans=1; 49 while(b!=0) 50 { 51 if(b&1) 52 ans=(ans*a)%mod; 53 b/=2; 54 a=(a*a)%mod; 55 } 56 return ans; 57 } 58 59 int main() 60 { 61 long long n,i; 62 while(~sc("%lld",&n)) 63 { 64 for(i=1;i<=n;++i) 65 sc("%lld",&a[i]); 66 long long ans=0; 67 for(i=1;i<=n;++i) 68 { 69 long long temp=a[i]*2; 70 for(long long j=1;j<=n;++j) 71 { 72 if(j==i) 73 continue; 74 temp*=((a[j]*a[j]-a[i]*a[i])%mod+mod)%mod; 75 temp%=mod; 76 } 77 ans+=qpow(temp,mod-2,mod); 78 ans%=mod; 79 } 80 pr("%lld\n",ans); 81 } 82 return 0; 83 } 84 85 /**************************************************************************************/ 86 87 long long maxx(long long a,long long b) 88 { 89 return a>b?a:b; 90 } 91 92 void swapp(long long &a,long long &b) 93 { 94 a^=b^=a^=b; 95 } 96 97 long long lowbit(long long n) 98 { 99 return n&(-n); 100 } 101 102 long long Del_bit_1(long long n) 103 { 104 return n&(n-1); 105 } 106 107 long long abss(long long a) 108 { 109 return a>0?a:-a; 110 } 111 112 double fabss(double a) 113 { 114 return a>0?a:-a; 115 } 116 117 long long minn(long long a,long long b) 118 { 119 return a<b?a:b; 120 }