結果

問題 No.1844 Divisors Sum Sum
ユーザー 👑 potato167potato167
提出日時 2021-08-25 04:25:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,179 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 202,908 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-04-20 03:23:57
合計ジャッジ時間 7,879 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 3 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
ll mod=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)


//Nの正の約数を列挙する
vector<long long> Divisors(long long N){
    vector<long long> p,q;
    long long i=1,K=0;
    while(i*i<N){
        if(N%i==0){
            p.push_back(i);
            q.push_back(N/i);
            K++;
        }
        i++;
    }
    if(i*i==N) p.push_back(i);
    for(int i=K-1;i>=0;i--){
        p.push_back(q[i]);
    }
    return p;
}

const int MAX_N=2e5;
const int MAX_P=1e9;
const int MAX_e=1e9;

//  rainy ~ 雨に打たれて ~
int main() {
	int N;
	cin>>N;
	assert(1<=N&&N<=MAX_N);
	vector<ll> P(N),e(N);
	set<ll> appear;
	ll multi=MAX_P;
	rep(i,N){
		cin>>P[i]>>e[i];
		assert(!appear.count(P[i]));
		appear.insert(P[i]);
		assert(2<=P[i]&&P[i]<=MAX_P);
		assert(1<=e[i]&&e[i]<=MAX_e);
		rep(j,e[i]){
			if(multi==0) break;
			multi/=P[i];
		}
	}
	if(multi==0){
		cout<<"-1\n";
		return 0;
	}
	ll X=1;
	rep(i,N){
		rep(j,e[i]) X*=P[i];
	}
	auto p=Divisors(X);
	ll ans=0;
	for(auto x:p){
		auto q=Divisors(x);
		for(auto y:q) ans+=y;
	}
	cout<<ans%mod<<endl;
}

0