版本比较
题解:P14967 Watching the Moon
正文
增加 4 行删除 4 行
59 行未改动6061626364656667683 行未改动727374757677787980818283848586878889909192939459 行未改动//#define int long long//#define double long double//#define debug(x) cout<<#x<<"->"<<x<<endl<<flush//#define endl '\n'//#define inf INT_MAXusing namespace std;const int N=5e6+7;//const int M=1e6+7;const int mod=1e9+7;3 行未改动ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);int n;cin >>n;int ans=0;int x;cin >>x;ans=x;int p=x;//p 第一个就是 a[1]int s=0;for(int i=2;i<=n;i++){int x;cin >>x;s=(s+p)%mod;//累加 p 求和// \sum{j=1}^{i} p[j] = sans=(((1ll*s*s)%mod)+ans+x)%mod;//加上答案p=((1ll*(1ll*p*p)%mod)*x)%mod;//求 p}cout<<ans;return 0;}/*p[i+1]=p[i]^2*a[i+1]*/```~~赛时被卡常了。~~59 行未改动6061626364656667683 行未改动727374757677787980818283848586878889909192939459 行未改动//#define int long long//#define double long double//#define debug(x) cout<<#x<<"->"<<x<<endl<<flush//#define endl '\n'//#define inf INT_MAXusing namespace std;const int N=5e6+7;//const int M=1e6+7;const int mod=1e9+7;3 行未改动ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);int n;cin >>n;int ans=0;int x;cin >>x;ans=x;int p=x;//p 第一个就是 a[1]int s=0;for(int i=2;i<=n;i++){int x;cin >>x;s=(s+p)%mod;//累加 p 求和// \sum{j=1}^{i} p[j] = sans=(((1ll*s*s)%mod)+ans+x)%mod;//加上答案p=((1ll*(1ll*p*p)%mod)*x)%mod;//求 p}cout<<ans;return 0;}/*p[i+1]=p[i]^2*a[i+1]*/```~~赛时被卡常了。~~