結果

問題 No.2561 みんな大好きmod 998
ユーザー 4O44O4
提出日時 2023-12-02 17:00:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 466 ms / 4,000 ms
コード長 914 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 172,916 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 17:00:55
合計ジャッジ時間 8,570 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 26 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 466 ms
6,548 KB
testcase_04 AC 439 ms
6,548 KB
testcase_05 AC 440 ms
6,548 KB
testcase_06 AC 443 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 67 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 438 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 321 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 89 ms
6,548 KB
testcase_27 AC 438 ms
6,548 KB
testcase_28 AC 117 ms
6,548 KB
testcase_29 AC 37 ms
6,548 KB
testcase_30 AC 117 ms
6,548 KB
testcase_31 AC 258 ms
6,548 KB
testcase_32 AC 47 ms
6,548 KB
testcase_33 AC 37 ms
6,548 KB
testcase_34 AC 439 ms
6,548 KB
testcase_35 AC 30 ms
6,548 KB
testcase_36 AC 31 ms
6,548 KB
testcase_37 AC 15 ms
6,548 KB
testcase_38 AC 67 ms
6,548 KB
testcase_39 AC 117 ms
6,548 KB
testcase_40 AC 118 ms
6,548 KB
testcase_41 AC 67 ms
6,548 KB
testcase_42 AC 117 ms
6,548 KB
testcase_43 AC 15 ms
6,548 KB
testcase_44 AC 50 ms
6,548 KB
testcase_45 AC 321 ms
6,548 KB
testcase_46 AC 38 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
int ctoi(char c){return c-'0';}
ll ctoll(char c){return c-'0';}

int ans = 0;
int n,k;
vector<ll>a;

void dfs(int index, int count, ll sum,vector<int>list){
     if(count == k ){
          ll val1 = sum%998LL;
          ll val2 = sum%998244353LL;
          if(val2 <= val1){
               ans++;
               ans%=998;
               /*
               rep(i,list.size()){
                    cout << list[i] << " ";
               }
               cout << endl;
               */
          }
          return;
     }
     if(index >= n)return;

     dfs(index+1,count,sum,list);
     list.push_back(index+1);
     dfs(index+1,count+1,sum+a[index],list);
     return;
}

int main(){
     cin >> n >> k;
     a.resize(n);
     rep(i,n)cin >> a[i];

     dfs(0,0,0LL,{});

     cout << ans << endl;
}
0