結果
| 問題 | No.2561 みんな大好きmod 998 |
| コンテスト | |
| ユーザー |
Shibaken28
|
| 提出日時 | 2023-12-04 14:57:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 517 ms / 4,000 ms |
| コード長 | 4,724 bytes |
| 記録 | |
| コンパイル時間 | 1,603 ms |
| コンパイル使用メモリ | 138,788 KB |
| 最終ジャッジ日時 | 2025-02-18 07:10:38 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
ソースコード
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#include <climits>
#include <cmath>
#include <functional>
#include <numeric>
#include <regex>
#include <array>
#include <fstream>
#include <sstream>
//#include<atcoder/modint>
//using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define repl(i,l,r) for (int i = l; i < (int)(r); i++)
#define all(a) a.begin(),a.end()
#define Pii pair<int,int>
#define Pll pair<long,long>
#define INFi 1000000001
#define INFl 1000000000000000001
#define ll long long
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<class T> void printArray(vector<T>&A){
for(T&a:A){
cout<<a<<" ";
}
cout<<endl;
}
template<class T> void printArrayln(vector<T>&A){
for(T&a:A){
cout<<a<<endl;
}
}
template<class T1,class T2> std::ostream &operator<<(std::ostream &out, const pair<T1,T2> &A){
cout<<"{"<<A.first<<","<<A.second<<"}";
return out;
}
template<class T1,class T2> std::ostream &operator<<(std::ostream &out, const map<T1,T2> &M){
for(const auto&A:M){
cout<<"{"<<A.first<<","<<A.second<<"}";
}
return out;
}
template<class T1> std::ostream &operator<<(std::ostream &out, const set<T1> &M){
cout<<"{";
for(const auto&A:M){
cout<<A<<", ";
}
cout<<"}"<<endl;
return out;
}
template<class T1> std::ostream &operator<<(std::ostream &out, const multiset<T1> &M){
cout<<"{";
for(const auto&A:M){
cout<<A<<", ";
}
cout<<"}"<<endl;
return out;
}
template<class T> std::ostream &operator<<(std::ostream &out, const vector<T> &A){
for(const T &a:A){
cout<<a<<" ";
}
return out;
}
void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head H, Tail... T) {
cout << H << " ";
print(T...);
}
template<class T> std::istream &operator>>(std::istream &in,vector<T>&A){
for(T&a:A){
std::cin>>a;
}
return in;
}
vector<vector<int>> permutations(int N){
vector<int> array(N);
vector<vector<int>> A(0);
for(int i=0;i<N;i++)array[i]=i;
do{
A.push_back(array);
}while(next_permutation(array.begin(),array.end()));
return A;
}
vector<vector<int>> permutation(int N,int U,bool h=false){
//0,1,2,3,...,N-1縺ョN蛟九°繧蔚蛟矩∈縺カ鬆・・
vector<vector<int>> A(0);
auto fun = [&h,&A,&N,&U](auto &fun,vector<int> &B)->void{
if((int)B.size()==U){
auto C=B;
do{
A.push_back(C);
}while(next_permutation(C.begin(),C.end()));
return;
}
int s = (h?0:-1);
if(!B.empty())s = B.back();
for(int x=s+(h?0:1);x<N;x++){
B.push_back(x);
fun(fun,B);
B.pop_back();
}
};
vector<int> C={};
fun(fun,C);
return A;
}
vector<vector<int>> combination(int N,int U,bool h=false){
//0,1,2,3,...,N-1縺ョN蛟九°繧蔚蛟矩∈縺カ邨・∩蜷医o縺幃・・
vector<vector<int>> A(0);
auto fun = [&h,&A,&N,&U](auto &fun,vector<int> &B)->void{
if((int)B.size()==U){
auto C=B;
A.push_back(B);
return;
}
int s = (h?0:-1);
if(!B.empty())s = B.back();
for(int x=s+(h?0:1);x<N;x++){
B.push_back(x);
fun(fun,B);
B.pop_back();
}
};
vector<int> C={};
fun(fun,C);
return A;
}
int main(void){
std::cin.tie(0)->sync_with_stdio(0);
long N,K;cin>>N>>K;
vector<long> A(N);
rep(i,N)cin>>A[i];
int cnt = 0;
auto B = combination(N,K,false);
for(auto&C:B){
long sum = 0;
for(auto&c:C){
sum += A[c];
}
if(sum%998244353<=sum%998)cnt++;
}
cout<<cnt%998<<endl;
}
Shibaken28