QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#79694#3724. Strange Primesjc061031AC ✓69ms3764kbC++171.4kb2023-02-20 19:19:332023-02-20 19:19:36

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-20 19:19:36]
  • 评测
  • 测评结果:AC
  • 用时:69ms
  • 内存:3764kb
  • [2023-02-20 19:19:33]
  • 提交

answer

#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define MOD 1000000007
#define P 10000000019ll
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n,a[100010];

inline void add1(int &x,int y)
{
	x+=y;
	if(x>=MOD) x-=MOD;
}

inline void add2(int &x,int y)
{
	x+=y;
	if(x<0) x+=MOD;
}

inline int my_pow(int x,int y)
{
	if(y==0) return 1;
	if(y==1) return x;
	int res=my_pow(x,y/2);
	if(y%2==0) return 1ll*res*res%MOD;
	else return 1ll*res*res%MOD*x%MOD;
}

signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	while(cin>>n){
		for(int i=1;i<=n;i++) cin>>a[i];
		int ans=1,res=1;
		for(int i=1;i<=n;i++) ans=1ll*ans*((P-a[i])%MOD)%MOD,res=1ll*res*(MOD-a[i])%MOD;
		add2(ans,-res);ans=1ll*ans*my_pow(P%MOD,MOD-2)%MOD;
		cout<<ans<<'\n';
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 69ms
memory: 3764kb

input:

10
2357 42596 7212 30898 43465 68984 60783 59520 53767 77560
10
39115 88080 83553 61736 90821 39690 13194 81396 38051 55993
10
95070 81321 71632 21071 10807 46105 66844 63678 47577 75132
10
43898 93215 26791 11849 61857 1423 76971 83489 52044 61325
10
22610 16613 90 53598 80110 42651 64942 67114 242...

output:

8747181
109223012
855771490
541976436
590061154
362989597
987338731
316507988
571293823
811262072
971678511
475746045
438611414
341241863
155506989
174497292
470085592
844919405
114498965
739370426
38587099
214008686
506810838
254574502
480440711
792847181
303917854
79001517
310250674
834963010
1907...

result:

ok 11305 numbers