結果

問題 No.1097 Remainder Operation
ユーザー hs0319boyhs0319boy
提出日時 2020-06-26 22:34:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,314 bytes
コンパイル時間 1,789 ms
コンパイル使用メモリ 174,276 KB
実行使用メモリ 10,492 KB
最終ジャッジ日時 2023-09-18 06:00:32
合計ジャッジ時間 6,311 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
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 AC 215 ms
4,628 KB
testcase_18 AC 242 ms
10,488 KB
testcase_19 AC 246 ms
10,164 KB
testcase_20 AC 243 ms
10,156 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:49:26: 警告: ‘num’ may be used uninitialized [-Wmaybe-uninitialized]
   49 |         else ans[i]=x[num]+((k-num)/(s-num))*(x[s]-x[num])+x[num+k%(s-num)]-x[num];
      |                          ^
main.cpp:37:22: 備考: ‘num’ はここで定義されています
   37 |     ll s=x.size();ll num;
      |                      ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n;cin>>n;
    vll a(n);rep(i,n)cin>>a[i];
    set<ll> r;
    vll x;x.push_back(0);
    ll tmp;ll sum=0;
    while(1){
        tmp=sum%n;
        if(r.count(tmp))break;
        r.insert(tmp);
        sum+=a[tmp];
        x.push_back(sum);
    }
    ll s=x.size();ll num;
    rep(i,s)if(x[i]%n==tmp){
        num=i;
        break;
    }
    s--;
    //cout<<s<<" "<<num<<endl;
    int q;cin>>q;
    ll k;vll ans(q);
    rep(i,q){
        cin>>k;
        if(k<=num)ans[i]=x[k];
        else ans[i]=x[num]+((k-num)/(s-num))*(x[s]-x[num])+x[num+k%(s-num)]-x[num];
    }
    rep(i,q)cout<<ans[i]<<endl;
}
0