結果

問題 No.1411 Hundreds of Conditions Sequences
ユーザー 👑 potato167potato167
提出日時 2022-02-17 00:01:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 774 ms / 2,000 ms
コード長 2,144 bytes
コンパイル時間 2,364 ms
コンパイル使用メモリ 213,332 KB
実行使用メモリ 86,388 KB
最終ジャッジ日時 2023-09-11 17:18:52
合計ジャッジ時間 53,731 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 571 ms
80,856 KB
testcase_01 AC 547 ms
80,688 KB
testcase_02 AC 544 ms
80,712 KB
testcase_03 AC 551 ms
80,860 KB
testcase_04 AC 593 ms
80,704 KB
testcase_05 AC 592 ms
80,848 KB
testcase_06 AC 577 ms
80,804 KB
testcase_07 AC 573 ms
80,752 KB
testcase_08 AC 584 ms
80,688 KB
testcase_09 AC 583 ms
80,716 KB
testcase_10 AC 583 ms
80,808 KB
testcase_11 AC 584 ms
80,704 KB
testcase_12 AC 739 ms
82,488 KB
testcase_13 AC 700 ms
82,292 KB
testcase_14 AC 645 ms
81,840 KB
testcase_15 AC 698 ms
82,200 KB
testcase_16 AC 594 ms
81,120 KB
testcase_17 AC 697 ms
82,176 KB
testcase_18 AC 736 ms
82,484 KB
testcase_19 AC 718 ms
82,768 KB
testcase_20 AC 610 ms
81,500 KB
testcase_21 AC 729 ms
82,820 KB
testcase_22 AC 626 ms
81,768 KB
testcase_23 AC 706 ms
82,536 KB
testcase_24 AC 553 ms
80,856 KB
testcase_25 AC 709 ms
82,628 KB
testcase_26 AC 652 ms
82,176 KB
testcase_27 AC 607 ms
81,500 KB
testcase_28 AC 676 ms
82,284 KB
testcase_29 AC 681 ms
81,116 KB
testcase_30 AC 644 ms
82,100 KB
testcase_31 AC 642 ms
81,760 KB
testcase_32 AC 730 ms
82,800 KB
testcase_33 AC 735 ms
82,820 KB
testcase_34 AC 726 ms
82,912 KB
testcase_35 AC 739 ms
82,964 KB
testcase_36 AC 737 ms
82,820 KB
testcase_37 AC 729 ms
82,852 KB
testcase_38 AC 728 ms
82,892 KB
testcase_39 AC 730 ms
82,804 KB
testcase_40 AC 728 ms
82,908 KB
testcase_41 AC 727 ms
82,912 KB
testcase_42 AC 714 ms
82,884 KB
testcase_43 AC 743 ms
82,968 KB
testcase_44 AC 719 ms
82,908 KB
testcase_45 AC 734 ms
82,980 KB
testcase_46 AC 730 ms
82,768 KB
testcase_47 AC 728 ms
82,872 KB
testcase_48 AC 726 ms
82,756 KB
testcase_49 AC 774 ms
82,824 KB
testcase_50 AC 730 ms
82,900 KB
testcase_51 AC 743 ms
82,976 KB
testcase_52 AC 728 ms
82,808 KB
testcase_53 AC 716 ms
82,984 KB
testcase_54 AC 729 ms
83,040 KB
testcase_55 AC 719 ms
82,756 KB
testcase_56 AC 721 ms
82,856 KB
testcase_57 AC 722 ms
82,896 KB
testcase_58 AC 730 ms
83,028 KB
testcase_59 AC 722 ms
82,804 KB
testcase_60 AC 716 ms
82,964 KB
testcase_61 AC 723 ms
82,752 KB
testcase_62 AC 620 ms
81,532 KB
testcase_63 AC 765 ms
86,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=1167167167167167167;
const int INF=100000000;
const ll mod=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}

ll jyo(ll x,ll y,ll z){
  ll H=y; //ここから
       ll a=1,b=x,c=1;
       while(H>0){
         a*=2;
         if(H%a!=0){
           H-=a/2;
           c*=b;
           c%=z;
         }
        b*=b;
         b%=z;
      } //ここまで
 return c;
}


void solve();

//  rainy ~ 雨に打たれて ~
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin>>t;
	rep(i,t) solve();
}

void solve(){
	int N;
	cin>>N;
	vector<ll> p(N);
	rep(i,N) cin>>p[i];
	ll M=1e6+10;
	vector<vector<pair<int,int>>> table(M);
	rep(i,M){
		if(i<2) continue;
		if(table[i].size()==0){
			for(int j=i;j<M;j+=i){
				int D=j;
				while(D%i==0){
					D/=i;
					table[j].push_back({i,j/D});
				}
			}
		}
	}
	map<pair<int,int>,int> m;
	rep(i,N){
		for(auto x:table[p[i]]) m[x]++;
	}
	ll base=1;
	ll D=1;
	rep(i,N) base=(base*p[i])%mod;
	for(auto x:m){
		//cout<<x.first.first<<" "<<x.first.second<<" "<<x.second<<"\n";
		D=(D*x.first.first)%mod;
	}
	//cout<<D<<" "<<base<<"\n";
	rep(i,N){
		ll ans=(base*jyo(p[i],mod-2,mod))%mod;
		ll tmp=D;
		for(auto x:table[p[i]]){
			if(m[x]==1) tmp=(tmp*jyo(x.first,mod-2,mod))%mod;
		}
		//cout<<ans<<" ";
		cout<<(ans-tmp+mod)%mod<<"\n";
	}
}
0