結果

問題 No.1411 Hundreds of Conditions Sequences
ユーザー chocoruskchocorusk
提出日時 2021-02-26 22:05:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 490 ms / 2,000 ms
コード長 2,001 bytes
コンパイル時間 3,597 ms
コンパイル使用メモリ 188,124 KB
実行使用メモリ 18,556 KB
最終ジャッジ日時 2024-04-10 12:50:18
合計ジャッジ時間 20,252 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,144 KB
testcase_01 AC 4 ms
6,272 KB
testcase_02 AC 4 ms
6,272 KB
testcase_03 AC 4 ms
6,144 KB
testcase_04 AC 4 ms
6,272 KB
testcase_05 AC 4 ms
6,272 KB
testcase_06 AC 4 ms
6,144 KB
testcase_07 AC 4 ms
6,016 KB
testcase_08 AC 3 ms
6,144 KB
testcase_09 AC 4 ms
5,888 KB
testcase_10 AC 3 ms
6,144 KB
testcase_11 AC 4 ms
6,272 KB
testcase_12 AC 238 ms
17,664 KB
testcase_13 AC 181 ms
16,768 KB
testcase_14 AC 98 ms
14,848 KB
testcase_15 AC 178 ms
16,732 KB
testcase_16 AC 18 ms
9,856 KB
testcase_17 AC 170 ms
16,620 KB
testcase_18 AC 245 ms
17,604 KB
testcase_19 AC 264 ms
18,048 KB
testcase_20 AC 98 ms
14,848 KB
testcase_21 AC 278 ms
18,184 KB
testcase_22 AC 108 ms
15,248 KB
testcase_23 AC 240 ms
17,688 KB
testcase_24 AC 5 ms
6,528 KB
testcase_25 AC 243 ms
17,664 KB
testcase_26 AC 175 ms
16,496 KB
testcase_27 AC 99 ms
15,104 KB
testcase_28 AC 201 ms
16,896 KB
testcase_29 AC 30 ms
11,776 KB
testcase_30 AC 158 ms
16,076 KB
testcase_31 AC 140 ms
15,944 KB
testcase_32 AC 277 ms
18,556 KB
testcase_33 AC 281 ms
18,404 KB
testcase_34 AC 281 ms
18,488 KB
testcase_35 AC 282 ms
18,304 KB
testcase_36 AC 280 ms
18,356 KB
testcase_37 AC 277 ms
18,304 KB
testcase_38 AC 280 ms
18,500 KB
testcase_39 AC 278 ms
18,304 KB
testcase_40 AC 280 ms
18,304 KB
testcase_41 AC 281 ms
18,316 KB
testcase_42 AC 281 ms
18,552 KB
testcase_43 AC 280 ms
18,216 KB
testcase_44 AC 279 ms
18,420 KB
testcase_45 AC 278 ms
18,432 KB
testcase_46 AC 278 ms
18,532 KB
testcase_47 AC 284 ms
18,304 KB
testcase_48 AC 280 ms
18,376 KB
testcase_49 AC 280 ms
18,512 KB
testcase_50 AC 284 ms
18,372 KB
testcase_51 AC 280 ms
18,304 KB
testcase_52 AC 297 ms
13,696 KB
testcase_53 AC 301 ms
13,824 KB
testcase_54 AC 299 ms
13,568 KB
testcase_55 AC 298 ms
13,696 KB
testcase_56 AC 298 ms
13,696 KB
testcase_57 AC 299 ms
13,824 KB
testcase_58 AC 306 ms
13,696 KB
testcase_59 AC 299 ms
13,568 KB
testcase_60 AC 296 ms
13,696 KB
testcase_61 AC 300 ms
13,696 KB
testcase_62 AC 490 ms
9,344 KB
testcase_63 AC 365 ms
17,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
vector<P> v[100010];
int emx[1000010];
int emx2[1000010];
int main()
{
    int n; cin>>n;
    int a[100010];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<n; i++){
        int x=a[i];
        for(int j=2; j*j<=x; j++){
            if(x%j==0){
                int e=0;
                while(x%j==0){
                    e++;
                    x/=j;
                }
                v[i].push_back({j, e});
                if(emx[j]<e){
                    emx2[j]=emx[j];
                    emx[j]=e;
                }else if(emx2[j]<e){
                    emx2[j]=e;
                }
            }
        }
        if(x>1){
            v[i].push_back({x, 1});
            if(emx[x]<1){
                emx2[x]=emx[x];
                emx[x]=1;
            }else if(emx2[x]<1){
                emx2[x]=1;
            }
        }
    }
    using mint=modint1000000007;
    mint tot=1;
    for(int i=0; i<n; i++) tot*=a[i];
    mint ans0=1;
    for(int i=2; i<1000000; i++){
        if(emx[i]){
            for(int j=0; j<emx[i]; j++) ans0*=i;
        }
    }
    for(int i=0; i<n; i++){
        mint ans=ans0;
        for(auto q:v[i]){
            int p=q.first, e=q.second;
            if(emx[p]==e){
                for(int j=0; j<emx[p]-emx2[p]; j++) ans/=mint(p);
            }
        }
        ans=tot/a[i]-ans;
        cout<<ans.val()<<endl;
    }
    return 0;
}
0