結果

問題 No.1084 積の積
ユーザー llewkcor2178llewkcor2178
提出日時 2020-06-23 17:46:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,975 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 172,168 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-16 20:02:42
合計ジャッジ時間 5,616 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:49:30: 警告: ‘b’ may be used uninitialized [-Wmaybe-uninitialized]
   49 |                 for(int j=i;j<=b;j++){
      |                             ~^~~
main.cpp:39:9: 備考: ‘b’ はここで定義されています
   39 |     int b;
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
ll L=1e9;
int quick_pow(ll x,ll p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}


int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    rep(i, N){
        cin>>A[i];
    }
    sort(A.begin(), A.end());
    if(A[0]==0){
        cout<<0<<endl;
    }else{
    ll C=A[0];
    int b;
    ll B[N];
    rep(i, N){
        B[i]=0;
    }
    for(int i=0;i<N;i++){
        if(i==0){
        }else{
            C/=A[i-1];
            if(C>=L){
                for(int j=i;j<=b;j++){
                    B[j]+=b-j+1;
                    cout<<B[j]<<endl;
                }
                continue;
            }else{
                b=min(b++, N-1);
            }
        }
        int j;
        if(i==0){
            b=0;
        }
        for(j=b+1;j<N;j++){
            C*=A[j];
            cout<<C<<endl;
            if(C>=L){
                b=j-1;
                break;
            }
        }
        if(j==N){
            b=N-1;
        }
        for(j=i;j<=b;j++){
            B[j]+=b-j+1;
            cout<<j<<" "<<B[j]<<endl;
        }
    }
    ll ans=1;
    rep(i, N){
        cout<<B[i]<<endl;
        ans*=quick_pow(A[i], B[i]);
        ans%=M;
    }
    cout<<ans<<endl;
    }
}
0