zoukankan      html  css  js  c++  java
  • 微积分题--HDU6472--艺术台阶

    题意:http://acm.hdu.edu.cn/showproblem.php?pid=6472

    rt。

    思路:https://www.cnblogs.com/graytido/p/12296710.html

    差不多了

      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>//freopen("C:\Users\13606\Desktop\Input.txt","r",stdin);
      6 #include <bitset>
      7 //#include <map>
      8 //#include<unordered_map>   http://acm.hdu.edu.cn/showproblem.php?pid=6472
      9 #include <vector>
     10 #include <stack>
     11 #include <set>
     12 #include <string.h>//strstr substr strcat
     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<int, vector<int>, greater<int> > q;//less
     18 #include <vector>//emplace_back
     19 //#include <math.h>
     20 #include <cassert>
     21 #include <iomanip>
     22 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
     23 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
     24 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
     25 //******************
     26 clock_t __START,__END;
     27 double __TOTALTIME;
     28 void _MS(){__START=clock();}
     29 void _ME(){__END=clock();__TOTALTIME=(double)(__END-__START)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
     30 //***********************
     31 #define rint register int
     32 #define fo(a,b,c) for(rint a=b;a<=c;++a)
     33 #define fr(a,b,c) for(rint a=b;a>=c;--a)
     34 #define mem(a,b) memset(a,b,sizeof(a))
     35 #define pr printf
     36 #define sc scanf
     37 #define ls rt<<1
     38 #define rs rt<<1|1
     39 typedef pair<int,int> PII;
     40 typedef vector<int> VI;
     41 typedef unsigned long long ull;
     42 typedef long long ll;
     43 typedef double db;
     44 const db E=2.718281828;
     45 const db PI=acos(-1.0);
     46 const ll INF=(1LL<<60);
     47 const int inf=(1<<30);
     48 const db ESP=1e-9;
     49 const int mod=(int)1e9+7;
     50 const int N=(int)1e6+10;
     51 ll qpow(ll a,ll b,ll mod){
     52     ll ans;
     53 //    a%=mod;
     54     ans=1;
     55     while(b!=0)
     56     {
     57         if(b&1)
     58             ans=(ans*a)%mod;
     59         b/=2;
     60         a=(a*a)%mod;
     61     }
     62     return ans;
     63 }
     64 
     65 ll Div[N];
     66 ll a[N];
     67 struct node
     68 {
     69     ll xi,zhi;
     70 };
     71 vector<node>v;
     72 
     73 void solve()
     74 {
     75     v.clear();
     76     int n;
     77     ll down=1;
     78     sc("%d",&n);
     79     for(int i=1;i<=n;++i)sc("%lld",&a[i]),down=down*Div[a[i]]%mod;
     80     for(int i=n-1;i>=1;--i)a[i]=min(a[i],a[i+1]);
     81     v.push_back({1,0});//系数1,指数0
     82     for(int i=n;i>=1;--i)
     83     {
     84         int sz=v.size();
     85         ll ans=0;
     86         for(int j=0;j<sz;++j)
     87         {
     88             v[j].zhi++;
     89             v[j].xi=(v[j].xi*Div[v[j].zhi])%mod;
     90             ans=(ans+(qpow(a[i],v[j].zhi,mod)*v[j].xi%mod+mod)%mod)%mod;
     91             v[j].xi=-v[j].xi;//变号
     92         }
     93         v.push_back({ans,0});
     94     }
     95     int sz=v.size();//400000003
     96     pr("%lld
    ",((v[sz-1].xi*down)%mod+mod)%mod);
     97 }
     98 
     99 int main()
    100 {
    101     for(int i=1;i<=2005;++i)Div[i]=qpow(i,mod-2,mod);
    102     pr("%lld
    ",1ll*25*Div[2]%mod);
    103     pr("%lld
    ",1ll*25*Div[2]%mod*Div[25]%mod);
    104     int T;
    105     sc("%d",&T);
    106     while(T--)solve();
    107     return 0;
    108 }
    109 
    110 /**************************************************************************************/
  • 相关阅读:
    IntelliJ IDEA基本设置
    git安装
    Git的作用与安装
    git是什么
    SpringMVC控制器类方法的返回值
    SpringMVC中Model机制
    什么是Nosql
    如何使用Jedis操作redis
    redis中数据类型操作命令
    redis的全局命令
  • 原文地址:https://www.cnblogs.com/--HPY-7m/p/12318891.html
Copyright © 2011-2022 走看看