submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s404502949 | p03776 | C++ | #include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
double eps=0.000001;
unsigned long long combi(int a,int b){
unsigned long long up=1,dn=1;
for(int i=0;i<b;i++){
up*=a-i;
dn*=b-i;
}
return up/dn;
}
int main(void){
int n,a,b,c,d;
scanf("%d%d%d",&n,&a,&b);
vector<unsigned long long> v(n);
for(int i=0;i<n;i++) scanf("%llu",&v[i]);
sort(v.begin(),v.end());
double ans1=1.0*accumulate(v.end()-a+1,v.end(),0)/a;
for(c=n-1;c>=0;c--) if(v[c]==v[n-a])break;
c=n-1-c;
unsigned long long ans2=0;
d=count(v.begin(),v.end(),v[n-a]);
for(int i=a;i<=b;i++){
if(fabs(ans1-1.0*accumulate(v.end()-i+1,v.end(),0)/i)<eps){
ans2+=combi(d,i-c);
}
}
printf("%f\n%llu\n",ans1,ans2);
}
| a.cc: In function 'int main()':
a.cc:29:8: error: 'fabs' was not declared in this scope; did you mean 'labs'?
29 | if(fabs(ans1-1.0*accumulate(v.end()-i+1,v.end(),0)/i)<eps){
| ^~~~
| labs
|
s111943095 | p03776 | C++ | #include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
double eps=0.000001;
unsigned long long combi(int a,int b){
unsigned long long up=1,dn=1;
for(int i=0;i<b;i++){
up*=a-i;
dn*=b-i;
}
return up/dn;
}
int main(void){
int n,a,b,c,d;
scanf("%d%d%d",&n,&a,&b);
vector<unsigned long long> v[n];
for(int i=0;i<n;i++) scanf("%llu",&v[i]);
sort(v.begin(),v.end());
double ans1=1.0*accumulate(v.end()-a+1,v.end(),0)/a;
for(c=n-1;c>=0;c--) if(v[c]==v[n-a])break;
c=n-1-c;
unsigned long long ans2=0;
d=count(v.begin(),v.end(),v[n-a]);
for(int i=a;i<=b;i++){
if(abs(ans1-1.0*accumulate(v.end()-i+1,v.end(),0)/i)<eps){
ans2+=combi(d,i-c);
}
}
printf("%f\n%llu\n",ans1,ans2);
}
| a.cc: In function 'int main()':
a.cc:22:10: error: request for member 'begin' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
22 | sort(v.begin(),v.end());
| ^~~~~
a.cc:22:20: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
22 | sort(v.begin(),v.end());
| ^~~
a.cc:23:32: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
23 | double ans1=1.0*accumulate(v.end()-a+1,v.end(),0)/a;
| ^~~
a.cc:23:44: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
23 | double ans1=1.0*accumulate(v.end()-a+1,v.end(),0)/a;
| ^~~
a.cc:27:13: error: request for member 'begin' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
27 | d=count(v.begin(),v.end(),v[n-a]);
| ^~~~~
a.cc:27:23: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
27 | d=count(v.begin(),v.end(),v[n-a]);
| ^~~
a.cc:29:34: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
29 | if(abs(ans1-1.0*accumulate(v.end()-i+1,v.end(),0)/i)<eps){
| ^~~
a.cc:29:46: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
29 | if(abs(ans1-1.0*accumulate(v.end()-i+1,v.end(),0)/i)<eps){
| ^~~
|
s524344522 | p03776 | C++ | #include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
double eps=0.000001;
unsigned long long combi(int a,int b){
unsigned long long up=1,dn=1;
for(int i=0;i<b;i++){
up*=a-i;
dn*=b-i;
}
return up/dn;
}
int main(void){
int n,a,b,c,d;
scanf("%d%d%d",&n,&a,&b);
vector<unsigned long long> v[n];
for(int i=0;i<n;i++) scanf("%llu",v[i]);
sort(v.begin(),v.end());
double ans1=1.0*accumulate(v.end()-a+1,v.end(),0)/a;
for(c=n-1;c>=0;c--) if(v[c]==v[n-a])break;
c=n-1-c;
unsigned long long ans2=0;
d=count(v.begin(),v.end(),v[n-a]);
for(int i=a;i<=b;i++){
if(abs(ans1-1.0*accumulate(v.end()-i+1,v.end(),0)/i)<eps){
ans2+=combi(d,i-c);
}
}
printf("%f\n%llu\n",ans1,ans2);
} | a.cc: In function 'int main()':
a.cc:22:10: error: request for member 'begin' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
22 | sort(v.begin(),v.end());
| ^~~~~
a.cc:22:20: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
22 | sort(v.begin(),v.end());
| ^~~
a.cc:23:32: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
23 | double ans1=1.0*accumulate(v.end()-a+1,v.end(),0)/a;
| ^~~
a.cc:23:44: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
23 | double ans1=1.0*accumulate(v.end()-a+1,v.end(),0)/a;
| ^~~
a.cc:27:13: error: request for member 'begin' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
27 | d=count(v.begin(),v.end(),v[n-a]);
| ^~~~~
a.cc:27:23: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
27 | d=count(v.begin(),v.end(),v[n-a]);
| ^~~
a.cc:29:34: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
29 | if(abs(ans1-1.0*accumulate(v.end()-i+1,v.end(),0)/i)<eps){
| ^~~
a.cc:29:46: error: request for member 'end' in 'v', which is of non-class type 'std::vector<long long unsigned int> [n]'
29 | if(abs(ans1-1.0*accumulate(v.end()-i+1,v.end(),0)/i)<eps){
| ^~~
|
s098746055 | p03776 | C++ | #include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
cerr << head << ", ";
DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ",";
os << "}";
return os;
}
std::vector<std::vector<long long>> comb(int n, int r) {
std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v;
}
int main() {
int n, a, b;
cin >> n >> a >> b;
VEC<LL> v(n);
map<LL, int> m;
REP(i, 0, n) {
cin >> v[i];
m[v[i]++];
}
LL ans = 0;
sort(ALL(v));
auto q = comb(50, 1);
int remain = a;
for (int i = n - 1; i >= 0; ) {
LL w = v[i];
int num = m[w];
if(remain>=num){
remain -= num;
i -= num;
}else{
ans = q[num][remain];
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:82:2: error: expected '}' at end of input
82 | }
| ^
a.cc:56:12: note: to match this '{'
56 | int main() {
| ^
|
s527992355 | p03776 | C++ | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
const int INF = numeric_limits<int>::max()/2;
vector<vector<ll>> comb2(ll n) {
vector<vector<ll>> v(n + 1,vector<ll>(n + 1, 0));
for (int i = 0; i < (int)v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < (int)v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,a,b;cin>>n>>a>>b;
vector<ll> v(n);
vector<vector<ll>> com=comb2(60,60);
map<ll,ll> mp,used;
for(int i=0;i<n;i++){
cin>>v[i];
mp[v[i]]++;
}
sort(v.rbegin(),v.rend());
ll sum=0;
for(int i=0;i<a;i++){
sum += v[i];
used[v[i]]++;
}
ld s = sum;
cout<<fixed<<setprecision(10)<<s/a<<endl;
if(v[0]!=v[a-1]) cout<<com[mp[v[a-1]]][used[v[a-1]]]<<endl;
else{
ll res=0;
for(int i=a;i<=min(mp[v[0]],b);i++){
res += com[mp[v[0]]][i];
}
cout<<res<<endl;
}
}
| a.cc: In function 'int main()':
a.cc:30:33: error: too many arguments to function 'std::vector<std::vector<long long int> > comb2(ll)'
30 | vector<vector<ll>> com=comb2(60,60);
| ~~~~~^~~~~~~
a.cc:10:20: note: declared here
10 | vector<vector<ll>> comb2(ll n) {
| ^~~~~
|
s696790265 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll comb[55][55];
void init() {
for(int i = 0; i <= 50; i++) {
comb[i][0] = 1;
comb[i][i] = 1;
for(int j = 1; j < i; j++) {
comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
}
}
}
ll l[55];
int main() {
init();
int n, a, b;
scanf("%d%d%d", &n, &a, &b);
map<ll, int> dp;
for(int i = 0; i < n; i++) {
scanf("%lld", &l[i]);
dp[l[i]]++;
}
sort(l, l+n);
for(int i = 0; i < n-1-i; i++) {
l[i] ^= l[n-1-i];
l[n-1-i] ^= l[i];
l[i] ^= l[n-1-i];
}
if(l[0] == l[a-1]) {
printf("%lld\n", l[0]);
ll amt = 0;
for(int i = a; i <= b; i++) {
if(i <= freq[l[0]]) {
amt += comb[freq[l[0]]][i];
}
}
printf("%lld\n", amt);
}
else {
ll pref = 0;
for(int i = 0; i < a; i++) pref += l[i];
printf("%.9f\n", pref / (double)a);
int use = 0;
for(int i = 0; i < a; i++) if(l[i] == l[a-1]) use++;
printf("%lld\n", comb[dp[l[a-1]]][use]);
}
} | a.cc: In function 'int main()':
a.cc:40:33: error: 'freq' was not declared in this scope; did you mean 'free'?
40 | if(i <= freq[l[0]]) {
| ^~~~
| free
|
s544130869 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll comb[55][55];
void init() {
for(int i = 0; i <= 50; i++) {
comb[i][0] = 1;
comb[i][i] = 1;
for(int j = 1; j < i; j++) {
comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
}
}
}
ll l[55];
int main() {
init();
int n, a, b;
scanf("%d%d%d", &n, &a, &b);
map<ll, int> dp;
for(int i = 0; i < n; i++) {
scanf("%lld", &l[i]);
dp[l[i]]++;
}
sort(l, l+n);
for(int i = 0; i < n-1-i; i++) {
l[i] ^= l[n-1-i];
l[n-1-i] ^= l[i];
l[i] ^= l[n-1-i];
}
if(l[0] == l[a-1]) {
printf("%lld\n", l[0]);
for(int i = a; i <= b; i++) {
if(i <= freq[l[0]]) {
amt += comb[freq[l[0]]][i];
}
}
printf("%lld\n", amt);
}
else {
ll pref = 0;
for(int i = 0; i < a; i++) pref += l[i];
printf("%.9f\n", pref / (double)a);
int use = 0;
for(int i = 0; i < a; i++) if(l[i] == l[a-1]) use++;
printf("%lld\n", comb[dp[l[a-1]]][use]);
}
} | a.cc: In function 'int main()':
a.cc:39:33: error: 'freq' was not declared in this scope; did you mean 'free'?
39 | if(i <= freq[l[0]]) {
| ^~~~
| free
a.cc:40:33: error: 'amt' was not declared in this scope
40 | amt += comb[freq[l[0]]][i];
| ^~~
a.cc:43:34: error: 'amt' was not declared in this scope
43 | printf("%lld\n", amt);
| ^~~
|
s790795809 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll comb[55][55];
void init() {
for(int i = 0; i <= 50; i++) {
comb[i][0] = 1;
comb[i][i] = 1;
for(int j = 1; j < i; j++) {
comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
}
}
}
ll l[55];
int main() {
init();
int n, a, b;
scanf("%d%d%d", &n, &a, &b);
map<ll, int> dp;
for(int i = 0; i < n; i++) {
scanf("%lld", &l[i]);
dp[l[i]]++;
}
sort(l, l+n);
for(int i = 0; i < n-1-i; i++) {
l[i] ^= l[n-1-i];
l[n-1-i] ^= l[i];
l[i] ^= l[n-1-i];
}
if(l[0] == l[a-1]) {
printf("%lld\n", l[0]);
ll amt = 0;
for(int i = a; i <= b; i++) {
if(l[i-1] == l[0]) {
amt += comb[dp[0]][i];
}
}
printf("%lld\n", amt);
}
else {
ll pref = 0;
for(int i = 0; i < a; i++) pref += l[i];
printf("%.9f\n", pref / (double)a);
int use = 0;
for(int i = 0; i < a; i++) if(l[i] == l[a-1]) use++;
printf("%lld\n", comb[freq[l[a-1]]][use]);
}
} | a.cc: In function 'int main()':
a.cc:52:39: error: 'freq' was not declared in this scope; did you mean 'free'?
52 | printf("%lld\n", comb[freq[l[a-1]]][use]);
| ^~~~
| free
|
s450455847 | p03776 | C++ | #include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
using namespace std;
long long int combination(long long int n,long long int r)
{
long long int i, a, b;
long long int c;
if (r>n / 2) r = n - r;
a = n;
b = 1;
c = 1L;
for (i = 0; i< r; i++) {
c = c * a / b;
a--;
b++;
}
return c;
}
int main() {
long long int vec1[1000],N, A, B,y=0,Y=0;
cin >> N >> A >> B;
vector<long long int> vec(N);
for (int i = 0; i < N; i++) {
cin >> vec[i];
}
for (long long int i = 0; i < N; i++) {
vec1[i] = 1;
}
long long int d=1;
sort(vec.begin(), vec.end(), greater<long long int>());
for (long long int i = 1; i < N; i++) {
if (vec[i] == vec[i - 1]) {
vec1[i] += vec1[i-1];
}
}
for (int i = N-1; i>0; i--) {
if (vec1[i-1] != 1)vec1[i-1] = vec1[i];
else {
vec1[i - 1] = vec1[i];
i--;
}
}
long double c;
if (vec1[0] == N) {
Y = vec[0] * A;
for (long long int i = A - 1; i < B; i++) {
y += combination(vec1[i], i - A + 2);
}
}
else {
for (long long int i = 0; i < A; i++) {
if (i != 0) {
if (vec[i] == vec[i - 1]) {
d++;
}
else {
d = 1;
}
}
Y += vec[i];
}
y = combination(vec1[A - 1], d);
}
c = Y / long double(A);
cout <<fixed <<setprecision(6)<<c<< endl;
cout << y << endl;
} | a.cc: In function 'int main()':
a.cc:83:17: error: expected primary-expression before 'long'
83 | c = Y / long double(A);
| ^~~~
|
s248800799 | p03776 | C | #include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// 内部定数
#define D_ITM_MAX 50 // 最大品物数
// 内部構造体 - 品物情報
typedef struct Itm {
long long mlVal; // 価値
int miCnt; // 数
} Itm;
// 内部変数
static Itm sz1Itm[D_ITM_MAX]; // 品物
static int siICnt; // 品物数
static int siISMin; // 品物選択数 - 最小
static int siISMax; // 品物選択数 - 最大
static long long sl2Comb[D_ITM_MAX + 5][D_ITM_MAX + 5]; // 組み合わせ表[n][m] = nCm
// 内部変数 - テスト用
#ifdef D_TEST
static int siRes;
static FILE *szpFpT, *szpFpA;
#endif
// ソート関数 - 品物 - 価値降順
int
fSortFnc(
const void *pzpVal1 // <I> 値1
, const void *pzpVal2 // <I> 値2
)
{
Itm *lzpVal1 = (Itm *)pzpVal1;
Itm *lzpVal2 = (Itm *)pzpVal2;
// 価値降順
if (lzpVal1->mlVal > lzpVal2->mlVal) {
return(-1);
}
else if (lzpVal1->mlVal < lzpVal2->mlVal) {
return(1);
}
return 0;
}
// 品物 - 数セット
int
fSetCnt(
)
{
int i;
// 数セット
int liNo = 0;
for (i = 1; i < siICnt; i++) {
if (sz1Itm[i].mlVal == sz1Itm[liNo].mlVal) { // 一致
sz1Itm[liNo].miCnt++;
}
else { // 不一致
liNo++;
sz1Itm[liNo].mlVal = sz1Itm[i].mlVal;
}
}
// 品物数更新
siICnt = liNo;
return 0;
}
// 組み合わせ表の作成
int
fMakeComb(
)
{
int i, j;
for (i = 0; i <= siICnt; ++i) {
for (j = 0; j <= i; ++j) {
if (j == 0 or j == i) {
sl2Comb[i][j] = 1;
}
else {
sl2Comb[i][j] = sl2Comb[i - 1][j - 1] + sl2Comb[i - 1][j];
}
}
}
return 0;
}
// 実行メイン
int
fMain(
int piTNo // <I> テスト番号 1~
)
{
int i;
char lc1Buf[1024], lc1Out[1024];
// テストファイルオープン
#ifdef D_TEST
sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
szpFpT = fopen(lc1Buf, "r");
sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
szpFpA = fopen(lc1Buf, "r");
siRes = 0;
#endif
// 品物数・品物選択数取得
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
sscanf(lc1Buf, "%d%d%d", &siICnt, &siISMin, &siISMax);
// 品物取得
for (i = 0; i < siICnt; i++) {
#ifdef D_TEST
fscanf(szpFpT, "%lld", &sz1Itm[i].mlVal);
#else
fscanf(stdin, "%lld", &sz1Itm[i].mlVal);
#endif
sz1Itm[i].miCnt = 1;
}
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
// 品物 - ソート
qsort(sz1Itm, siICnt, sizeof(Itm), fSortFnc);
// 最大平均 - 取得
long long llSum = 0;
for (i = 0; i < siISMin; i++) {
llSum += sz1Itm[i].mlVal;
}
double ldAvg = (double)llSum / (double)siISMin;
// 最大平均 - 出力
sprintf(lc1Out, "%.6lf\n", ldAvg);
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
if (strcmp(lc1Buf, lc1Out)) {
siRes = -1;
}
#else
printf("%s", lc1Out);
#endif
// 組み合わせ表の作成
fMakeComb();
// 品物 - 数セット
fSetCnt();
long long llPtn = 0;
// 最大平均時の品物数のパターン
if (sz1Itm[0].miCnt <= siISMin) { // 1種類のみ
// 対象の品物取得
int liCnt = siISMin - sz1Itm[0].miCnt; // 残数
int liNo = 1;
while (liCnt >= sz1Itm[liNo].miCnt) {
liCnt -= sz1Itm[liNo].miCnt;
liNo++;
}
// パターン数
llPtn = sl2Comb[sz1Itm[liNo].miCnt][liCnt];
}
else { // 2種類以上
// 品物数
int liCnt = 0;
if (siISMax < sz1Itm[0].miCnt) {
liCnt = siISMax;
}
else {
liCnt = sz1Itm[0].miCnt;
}
// パターン数加算
for (i = siISMin; i <= siISMax; i++) {
llPtn += sl2Comb[sz1Itm[0].miCnt][i];
}
}
// パターン数の出力
sprintf(lc1Out, "%lld\n", llPtn);
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
if (strcmp(lc1Buf, lc1Out)) {
siRes = -1;
}
#else
printf("%s", lc1Out);
#endif
// テストファイルクローズ
#ifdef D_TEST
fclose(szpFpT);
fclose(szpFpA);
#endif
// テスト結果
#ifdef D_TEST
if (siRes == 0) {
printf("OK %d\n", piTNo);
}
else {
printf("NG %d\n", piTNo);
}
#endif
return 0;
}
int
main()
{
#ifdef D_TEST
int i;
for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
fMain(i);
}
#else
fMain(0);
#endif
return 0;
}
| main.c: In function 'fMakeComb':
main.c:85:35: error: expected ')' before 'or'
85 | if (j == 0 or j == i) {
| ~ ^~~
| )
|
s675043059 | p03776 | C | #include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// 内部定数
#define D_ITM_MAX 50 // 最大品物数
// 内部構造体 - 品物情報
typedef struct Itm {
long long mlVal; // 価値
int miCnt; // 数
} Itm;
// 内部変数
static Itm sz1Itm[D_ITM_MAX]; // 品物
static int siICnt; // 品物数
static int siISMin; // 品物選択数 - 最小
static int siISMax; // 品物選択数 - 最大
static long long sl2Comb[D_ITM_MAX + 5][D_ITM_MAX + 5]; // 組み合わせ表[n][m] = nCm
// 内部変数 - テスト用
#ifdef D_TEST
static int siRes;
static FILE *szpFpT, *szpFpA;
#endif
// ソート関数 - 品物 - 価値降順
int
fSortFnc(
const void *pzpVal1 // <I> 値1
, const void *pzpVal2 // <I> 値2
)
{
Itm *lzpVal1 = (Itm *)pzpVal1;
Itm *lzpVal2 = (Itm *)pzpVal2;
// 価値降順
if (lzpVal1->mlVal > lzpVal2->mlVal) {
return(-1);
}
else if (lzpVal1->mlVal < lzpVal2->mlVal) {
return(1);
}
return 0;
}
// 品物 - 数セット
int
fSetCnt(
)
{
int i;
// 数セット
int liNo = 0;
for (i = 1; i < siICnt; i++) {
if (sz1Itm[i].mlVal == sz1Itm[liNo].mlVal) { // 一致
sz1Itm[liNo].miCnt++;
}
else { // 不一致
liNo++;
sz1Itm[liNo].mlVal = sz1Itm[i].mlVal;
}
}
// 品物数更新
siICnt = liNo;
return 0;
}
// 組み合わせ表の作成
int
fMakeComb(
)
{
int i, j;
for (i = 0; i <= siICnt; ++i) {
for (j = 0; j <= i; ++j) {
if (j == 0 or j == i) {
sl2Comb[i][j] = 1;
}
else {
sl2Comb[i][j] = sl2Comb[i - 1][j - 1] + sl2Comb[i - 1][j];
}
}
}
return 0;
}
// 実行メイン
int
fMain(
int piTNo // <I> テスト番号 1~
)
{
int i;
char lc1Buf[1024], lc1Out[1024];
// テストファイルオープン
#ifdef D_TEST
sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
szpFpT = fopen(lc1Buf, "r");
sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
szpFpA = fopen(lc1Buf, "r");
siRes = 0;
#endif
// 品物数・品物選択数取得
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
sscanf(lc1Buf, "%d%d%d", &siICnt, &siISMin, &siISMax);
// 品物取得
for (i = 0; i < siICnt; i++) {
#ifdef D_TEST
fscanf(szpFpT, "%lld", &sz1Itm[i].mlVal);
#else
fscanf(stdin, "%lld", &sz1Itm[i].mlVal);
#endif
sz1Itm[i].miCnt = 1;
}
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
// 品物 - ソート
qsort(sz1Itm, siICnt, sizeof(Itm), fSortFnc);
// 最大平均 - 取得
long long llSum = 0;
for (i = 0; i < siISMin; i++) {
llSum += sz1Itm[i].mlVal;
}
double ldAvg = (double)llSum / (double)siISMin;
// 最大平均 - 出力
sprintf(lc1Out, "%.6lf\n", ldAvg);
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
if (strcmp(lc1Buf, lc1Out)) {
siRes = -1;
}
#else
printf("%s", lc1Out);
#endif
// 組み合わせ表の作成
fMakeComb();
// 品物 - 数セット
fSetCnt();
long long llPtn = 0;
// 最大平均時の品物数のパターン
if (sz1Itm[0].miCnt <= siISMin) { // 1種類のみ
// 対象の品物取得
int liCnt = siISMin - sz1Itm[0].miCnt; // 残数
int liNo = 1;
while (liCnt >= sz1Itm[liNo].miCnt) {
liCnt -= sz1Itm[liNo].miCnt;
liNo++;
}
// パターン数
llPtn = sl2Comb[sz1Itm[liNo].miCnt][liCnt];
}
else { // 2種類以上
// 品物数
int liCnt = 0;
if (siISMax < sz1Itm[0].miCnt) {
liCnt = siISMax;
}
else {
liCnt = sz1Itm[0].miCnt;
}
// パターン数加算
for (i = siISMin; i <= siISMax; i++) {
llPtn += sl2Comb[sz1Itm[0].miCnt][i];
}
}
// パターン数の出力
sprintf(lc1Out, "%lld\n", llPtn);
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
if (strcmp(lc1Buf, lc1Out)) {
siRes = -1;
}
#else
printf("%s", lc1Out);
#endif
// テストファイルクローズ
#ifdef D_TEST
fclose(szpFpT);
fclose(szpFpA);
#endif
// テスト結果
#ifdef D_TEST
if (siRes == 0) {
printf("OK %d\n", piTNo);
}
else {
printf("NG %d\n", piTNo);
}
#endif
return 0;
}
int
main()
{
#ifdef D_TEST
int i;
for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
fMain(i);
}
#else
fMain(0);
#endif
return 0;
}
| main.c: In function 'fMakeComb':
main.c:85:35: error: expected ')' before 'or'
85 | if (j == 0 or j == i) {
| ~ ^~~
| )
|
s121530433 | p03776 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int64_t comb[60][60];
int main() {
rep(i, 55) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i) {
comb[i][j] = 1;
} else {
comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
}
}
}
int N, A, B; cin >> N >> A >> B;
vector<int64_t> v(N);
rep(i, N) cin >> v[i];
sort(v.rbegin(), v.rend());
printf("%.16f\n", std::accumulate(v.begin(), v.begin() + A, 0LL) / (double) A);
int lidx = 0;
for (int i = A - 1; i >= 0; i--) {
if (v[i] > v[A - 1]) {
lidx = i + 1;
break;
}
}
int ridx = N;
REP(i, A, min(N, B + 1)) {
if (v[A - 1] > v[i]) {
ridx = i;
break;
}
}
int64_t sum = 0;
auto CountTarget = ridx - lidx;
if (v[A - 1] != v[0]) {
assert(lidx == 0);
cout << comb[CountTarget][A] << "\n";
} else {
REP(n, A, min(B, CountTarget) + 1) {
sum += comb[CountTarget][n];
}
cout << sum << "\n";
}
}
| a.cc: In function 'int main()':
a.cc:50:17: error: 'assert' was not declared in this scope
50 | assert(lidx == 0);
| ^~~~~~
a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
4 | #include <numeric>
+++ |+#include <cassert>
5 |
|
s643876694 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vl = vector<ll>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using vs = vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF ((ll)1ll<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384
template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }
//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
//constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
//
ll nCr[51][51];
void comb(int n) {
rep(i, n+1) {
rep(j, i + 1) {
if (j == 0 || j == i) {
nCr[i][j] = 1ll;
}
else {
nCr[i][j] = nCr[i - 1][j - 1] + nCr[i - 1][j];
}
}
}
}
int main() {
//cin.tie(0); ios::sync_with_stdio(false);
int n, a, b;
cin >> n >> a >> b;
comb(n);
ll ans = 0;
vector<double> v(n);
vector<double> dp(n + 1, -1);
dp[0] = 0;
rep(i, n) {
cin >> v[i];
}
sort(all(v),greater<ll>());
ll sum = 0;
rep(i, a) {
sum += v[i];
}
fcout(10) << (sum / (double)a) << endl;
if (v[0] == v[a - 1]) {
int cntn = 0;
rep(i, v.size()) {
if (v[i] == v[a - 1]) cntn++;
}
rep(i, a, b + 1) {
ans += nCr[cntn][i];
}
cout << ans << endl;
}
else {
ll ans = 0;
int pos = 0;
int cntn = 0, cntr = 0;
rep(i, v.size()) {
if (v[i] == v[a - 1]) {
cntn++;
if (i < a)pos++;
}
}
cout << nCr[cntn][pos] << endl;
}
} | a.cc:71:32: error: macro "rep" passed 3 arguments, but takes just 2
71 | rep(i, a, b + 1) {
| ^
a.cc:12:9: note: macro "rep" defined here
12 | #define rep(i,n) range(i,0,n)
| ^~~
a.cc: In function 'int main()':
a.cc:71:17: error: 'rep' was not declared in this scope
71 | rep(i, a, b + 1) {
| ^~~
|
s228073028 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vl = vector<ll>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using vs = vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF ((ll)1ll<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384
template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }
//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
//constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
//
ll nCr[51][51];
void comb(int n) {
rep(i, n+1) {
rep(j, i + 1) {
if (j == 0 || j == i) {
nCr[i][j] = 1ll;
}
else {
nCr[i][j] = nCr[i - 1][j - 1] + nCr[i - 1][j];
}
}
}
}
int main() {
//cin.tie(0); ios::sync_with_stdio(false);
int n, a, b;
cin >> n >> a >> b;
comb(n);
ll ans = 0;
vector<double> v(n);
vector<double> dp(n + 1, -1);
dp[0] = 0;
rep(i, n) {
cin >> v[i];
}
sort(all(v),greater<ll>());
ll sum = 0;
rep(i, a) {
sum += v[i];
}
fcout(10) << (sum / (double)a) << endl;
if (v[0] == v[a - 1]) {
int cntn = 0;
rep(i, v.size()) {
if (v[i] == v[a - 1]) cntn++;
}
rep(i, a, b + 1) {
ans += nCr[cntn][i];
}
cout << ans << endl;
}
else {
ll ans = 0;
int pos = 0;
int cntn = 0, cntr = 0;
rep(i, v.size()) {
if (v[i] == v[a - 1]) {
cntn++;
if (i < a)pos++;
}
}
cout << nCr[cntn][pos] << endl;
}
} | a.cc:71:32: error: macro "rep" passed 3 arguments, but takes just 2
71 | rep(i, a, b + 1) {
| ^
a.cc:12:9: note: macro "rep" defined here
12 | #define rep(i,n) range(i,0,n)
| ^~~
a.cc: In function 'int main()':
a.cc:71:17: error: 'rep' was not declared in this scope
71 | rep(i, a, b + 1) {
| ^~~
|
s150863945 | p03776 | C | #include<stdio.h>
int main(){
long long int n,a,b,i,j,s=51,t=0;
long long int v[50],temp,sum=0,cnt=1;
scanf("%lld %lld %lld",&n,&a,&b);
for(i=0;i<n;i++)
scanf("%lld",&v[i]);
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(v[i]<v[j]){
temp=v[i];
v[i]=v[j];
v[j]=temp;
}
}
}
for(i=0;i<a;i++)
sum+=v[i];
printf("%lf\n",(double)sum/(double)a);
for(i=0;i<n;i++){
if(s==51&&v[i]==v[a-1])
s=i;
if(v[i]==v[a-1])
t=i;
}
sum=0;
if(t==a-1)
printf("1\n");
else if(v[0]==v[a-1]){
for(i=a;i<=b;i++){
if(i<=t+1){
cnt=1;
for(j=0;j<i;j++){
cnt*=(t+1-j);
cnt/=j+1;
}
sum+=cnt;
}
}
printf("%lld\n",sum);
}
else{
for(j=s;j<a;j++){
cnt*=(t+1-j);
cnt/=(j-s+1);
sum+=cnt;
printf("%lld\n",sum);
}
} | main.c: In function 'main':
main.c:49:1: error: expected declaration or statement at end of input
49 | }
| ^
|
s712668895 | p03776 | C++ | #include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;
// pascal's triangle // C[n][k] -> nCk // O(n^2)
const int MAX_N = 10000;
ll C[MAX_N][MAX_N];
void comb_table(int n){
REP(i,n+1){
REP(j,i+1){
if(j==0 || j==i){
C[i][j]=1LL;
}else{
C[i][j]=(C[i-1][j-1]+C[i-1][j]);
}
}
}
}
int main(){
ll n, a, b;
cin >> n >>a >> b;
ll v[n];
REP(i,n)cin >> v[i];
sort(v, v+n);
double ave = 0;
REP(i,a){
ave += v[n-1-i];
}
ave /= double(a);
ll x = v[n-a];
comb_table(51);
if(ave == x){
int xnum = upper_bound(v, v+n, x) - lower_bound(v, v+n, x);
ll ans = 0;
for(int i = a; i <= min(b,xnum); i++){
ans += C[xnum][i];
}
cout.precision(20);
cout << fixed << ave << endl;
cout << ans << endl;
cout << "hey" << endl;
}else{
int xnum = upper_bound(v, v+n, x) - lower_bound(v, v+n, x);
int xina = (upper_bound(v, v+n, x) - v) - (n - a);
cout.precision(20);
cout << fixed << ave << endl;
cout << C[xnum][xina] << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:69:28: error: no matching function for call to 'min(ll&, int&)'
69 | for(int i = a; i <= min(b,xnum); i++){
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:69:28: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
69 | for(int i = a; i <= min(b,xnum); i++){
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:69:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
69 | for(int i = a; i <= min(b,xnum); i++){
| ~~~^~~~~~~~
|
s043174517 | p03776 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1e18;
ll C[51][51];
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, A, B;
cin >> N >> A >> B;
vector<ll> V(N);
for (auto&& v : V) {
cin >> v;
}
sort(V.begin(), V.end(), greater<ll>());
double ave = 0;
double sum = 0;
for (ll i = 0; i < A; i++) {
sum += V[i];
}
ave = sum / A;
for (ll i = A; i < B; i++) {
sum += V[i];
ave = max(ave, sum / (i + 1));
}
cout << setprecision(20) << ave << endl;
for (ll i = 0; i <= N; i++) {
for (ll j = 0; j <= i; j++) {
if (j == 0 || j == i) {
C[i][j] = 1LL;
} else {
C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
}
}
}
ll same = 1;
for (ll i = 0; i < A - 1; i++) {
if (V[i] == V[A - 1]) {
same++;
}
}
if (same == A) {
ll Bp = 0;
for (auto v : V) {
if (v == V[A - 1]) {
Bp++;
}
}
ll ans = (1LL << Bp) - (1LL << (A - 1));
cout << ans << endl;
} else {
ll r = same;
ll n = 0;
for (auto v : V) {
if (v == V[A - 1]) {
n++;
}
}
cout << C[n][r] << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:48:13: error: 'setprecision' was not declared in this scope
48 | cout << setprecision(20) << ave << endl;
| ^~~~~~~~~~~~
a.cc:14:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
13 | #include <unordered_set>
+++ |+#include <iomanip>
14 |
|
s974267723 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
int a[100], dp[100][100];
int calc(int l, int r, int n){
int ans = 0;
for(int i = l;i <= r;i++)ans += dp[n][i];
return ans;
}
void init(){
dp[0][0] = 1;
for(int i = 1;i <= 51;i++){
dp[i][0] = 1;
for(int j = 1;j <= 51;j++)
dp[i][j] = dp[i-1][j-1]+dp[i-1][j];
}
}
signed main(){
init();
int n, l, r;
scanf("%lld%lld%lld", &n, &l, &r);
for(int i = 1;i <= n;i++)scanf("%lld", &a[i]);
sort(a+1, a+n+1, greater<int>());
int sum = 0, s1 = 0, s2 = 0;
for(int i = 1;i <= n;i++){
if(i <= l)sum += a[i];
if(a[i] > a[l])s1++;
if(a[i] == a[l])s2++;
}
printf("%lf\n", (double)sum/l);
if(s1 == 0)printf("%lld\n", calc(l, r, s2));
elseprintf("%lld\n", dp[s2][l-s1]);
return 0;
} | a.cc: In function 'int main()':
a.cc:37:9: error: 'elseprintf' was not declared in this scope; did you mean 'vswprintf'?
37 | elseprintf("%lld\n", dp[s2][l-s1]);
| ^~~~~~~~~~
| vswprintf
|
s009849461 | p03776 | C++ | #include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
//#define ll __int64
#define __int64 long long
#define P pair<ll,ll>
const ll mod=1000000007;
int n,a,b;
ll t[111111];
/*
ll C(ll y,ll z){
ll a=1,b=1;
for(ll i=0;i<z;i++)a*=y-i;
for(ll i=1;i<=z;i++)b*=i;
return a/b;
}*/
ll m[100][100];
ll C(ll n,ll r){
if(m[n][r]!=0)return m[n][r];
if(n==r)return m[n][r]=1;
if(r==1)return m[n][r]=n;
return m[n][r]=C(n-1,r)+C(n-1,r-1);
}
int main(){
//cout<<C((ll)50,(ll)25)<<endl;
cin>>n>>a>>b;
rep(i,n)cin>>t[i];
sort(t,t+n,greater<ll>());
a--;
b--;
ll ma=t[0];
ll pt=0,cnt=0;
rep(i,a+1)cnt+=t[i];
if(t[a]!=ma){
int i=a;
ll tmp=t[a];
while(tmp==t[i])i++,pt++;
double s=(double)cnt/(double)(a+1);
printf("%.10lf\n",s);
cout<<pt<<endl;
}
else{
double s=(double)cnt/(double)(a+1);
printf("%.10lf\n",s);
int pos=a;
ll tmp=t[a];
while(tmp==t[pos])pos++;
for(int i=a+1;i<=b+1;i++)pt+=C(pos,i);
cout<<pt<<endl;
}
}
| a.cc:19:7: error: 'll' does not name a type
19 | const ll mod=1000000007;
| ^~
a.cc:21:1: error: 'll' does not name a type
21 | ll t[111111];
| ^~
a.cc:30:1: error: 'll' does not name a type
30 | ll m[100][100];
| ^~
a.cc:32:1: error: 'll' does not name a type
32 | ll C(ll n,ll r){
| ^~
a.cc: In function 'int main()':
a.cc:41:22: error: 't' was not declared in this scope
41 | rep(i,n)cin>>t[i];
| ^
a.cc:42:14: error: 't' was not declared in this scope; did you mean 'tm'?
42 | sort(t,t+n,greater<ll>());
| ^
| tm
a.cc:42:28: error: 'll' was not declared in this scope
42 | sort(t,t+n,greater<ll>());
| ^~
a.cc:42:30: error: template argument 1 is invalid
42 | sort(t,t+n,greater<ll>());
| ^
a.cc:45:11: error: expected ';' before 'ma'
45 | ll ma=t[0];
| ^~~
| ;
a.cc:46:11: error: expected ';' before 'pt'
46 | ll pt=0,cnt=0;
| ^~~
| ;
a.cc:47:19: error: 'cnt' was not declared in this scope; did you mean 'int'?
47 | rep(i,a+1)cnt+=t[i];
| ^~~
| int
a.cc:49:18: error: 'ma' was not declared in this scope; did you mean 'a'?
49 | if(t[a]!=ma){
| ^~
| a
a.cc:51:19: error: expected ';' before 'tmp'
51 | ll tmp=t[a];
| ^~~~
| ;
a.cc:52:23: error: 'tmp' was not declared in this scope; did you mean 'tm'?
52 | while(tmp==t[i])i++,pt++;
| ^~~
| tm
a.cc:52:37: error: 'pt' was not declared in this scope; did you mean 'pb'?
52 | while(tmp==t[i])i++,pt++;
| ^~
| pb
a.cc:53:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
53 | double s=(double)cnt/(double)(a+1);
| ^~~
| int
a.cc:55:23: error: 'pt' was not declared in this scope; did you mean 'pb'?
55 | cout<<pt<<endl;
| ^~
| pb
a.cc:58:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
58 | double s=(double)cnt/(double)(a+1);
| ^~~
| int
a.cc:61:19: error: expected ';' before 'tmp'
61 | ll tmp=t[a];
| ^~~~
| ;
a.cc:62:23: error: 'tmp' was not declared in this scope; did you mean 'tm'?
62 | while(tmp==t[pos])pos++;
| ^~~
| tm
a.cc:63:42: error: 'pt' was not declared in this scope; did you mean 'pb'?
63 | for(int i=a+1;i<=b+1;i++)pt+=C(pos,i);
| ^~
| pb
a.cc:63:46: error: 'C' was not declared in this scope
63 | for(int i=a+1;i<=b+1;i++)pt+=C(pos,i);
| ^
a.cc:64:23: error: 'pt' was not declared in this scope; did you mean 'pb'?
64 | cout<<pt<<endl;
| ^~
| pb
|
s691502453 | p03776 | C++ | #include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define __int64 long long
#define P pair<ll,ll>
const ll mod=1000000007;
int n,a,b;
ll t[111111];
/*
ll C(ll y,ll z){
ll a=1,b=1;
for(ll i=0;i<z;i++)a*=y-i;
for(ll i=1;i<=z;i++)b*=i;
return a/b;
}*/
ll m[100][100];
ll C(ll n,ll r){
if(m[n][r]!=0)return m[n][r];
if(n==r)return m[n][r]=1;
if(r==1)return m[n][r]=n;
return m[n][r]=C(n-1,r)+C(n-1,r-1);
}
int main(){
//cout<<C((ll)50,(ll)25)<<endl;
cin>>n>>a>>b;
rep(i,n)cin>>t[i];
sort(t,t+n,greater<ll>());
a--;
b--;
ll ma=t[0];
ll pt=0,cnt=0;
rep(i,a+1)cnt+=t[i];
if(t[a]!=ma){
int i=a;
ll tmp=t[a];
while(tmp==t[i])i++,pt++;
double s=(double)cnt/(double)(a+1);
printf("%.10lf\n",s);
cout<<pt<<endl;
}
else{
double s=(double)cnt/(double)(a+1);
printf("%.10lf\n",s);
int pos=a;
ll tmp=t[a];
while(tmp==t[pos])pos++;
for(int i=a+1;i<=b+1;i++)pt+=C(pos,i);
cout<<pt<<endl;
}
}
| a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:19:7: note: in expansion of macro 'll'
19 | const ll mod=1000000007;
| ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:21:1: note: in expansion of macro 'll'
21 | ll t[111111];
| ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:30:1: note: in expansion of macro 'll'
30 | ll m[100][100];
| ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:32:1: note: in expansion of macro 'll'
32 | ll C(ll n,ll r){
| ^~
a.cc: In function 'int main()':
a.cc:41:22: error: 't' was not declared in this scope
41 | rep(i,n)cin>>t[i];
| ^
a.cc:42:14: error: 't' was not declared in this scope; did you mean 'tm'?
42 | sort(t,t+n,greater<ll>());
| ^
| tm
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:42:28: note: in expansion of macro 'll'
42 | sort(t,t+n,greater<ll>());
| ^~
a.cc:42:30: error: template argument 1 is invalid
42 | sort(t,t+n,greater<ll>());
| ^
a.cc:45:12: error: expected ';' before 'ma'
45 | ll ma=t[0];
| ^~
a.cc:46:12: error: expected ';' before 'pt'
46 | ll pt=0,cnt=0;
| ^~
a.cc:47:19: error: 'cnt' was not declared in this scope; did you mean 'int'?
47 | rep(i,a+1)cnt+=t[i];
| ^~~
| int
a.cc:49:18: error: 'ma' was not declared in this scope; did you mean 'a'?
49 | if(t[a]!=ma){
| ^~
| a
a.cc:51:20: error: expected ';' before 'tmp'
51 | ll tmp=t[a];
| ^~~
a.cc:52:23: error: 'tmp' was not declared in this scope; did you mean 'tm'?
52 | while(tmp==t[i])i++,pt++;
| ^~~
| tm
a.cc:52:37: error: 'pt' was not declared in this scope; did you mean 'pb'?
52 | while(tmp==t[i])i++,pt++;
| ^~
| pb
a.cc:53:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
53 | double s=(double)cnt/(double)(a+1);
| ^~~
| int
a.cc:55:23: error: 'pt' was not declared in this scope; did you mean 'pb'?
55 | cout<<pt<<endl;
| ^~
| pb
a.cc:58:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
58 | double s=(double)cnt/(double)(a+1);
| ^~~
| int
a.cc:61:20: error: expected ';' before 'tmp'
61 | ll tmp=t[a];
| ^~~
a.cc:62:23: error: 'tmp' was not declared in this scope; did you mean 'tm'?
62 | while(tmp==t[pos])pos++;
| ^~~
| tm
a.cc:63:42: error: 'pt' was not declared in this scope; did you mean 'pb'?
63 | for(int i=a+1;i<=b+1;i++)pt+=C(pos,i);
| ^~
| pb
a.cc:63:46: error: 'C' was not declared in this scope
63 | for(int i=a+1;i<=b+1;i++)pt+=C(pos,i);
| ^
a.cc:64:23: error: 'pt' was not declared in this scope; did you mean 'pb'?
64 | cout<<pt<<endl;
| ^~
| pb
|
s482851660 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007
ll C[51][51];
void comb_table(int N){
for(int i=0;i<=N;i++){
for(int j=0;j<=i;j++){
if(j==0||j==i){
C[i][j]=1LL;
}else{
C[i][j]=(C[i-1][j-1]+C[i-1][j]);
}
}
}
}
int main(){
comb_table(50);
int n,a,b;
cin>>n>>a>>b;
vector<ll> v(n);
for(int i=0;i<n;i++) cin>>v[i];
sort(v.rbegin(),v.rend());
ull sum=0;
double ans=-1.0;
for(int i=0;i<b;i++){
sum+=v[i];
if(i>=a-1){
ans=max(ans, sum/(i+1.0));
}
}
ull ans2=0;
for(int i=b-1;i>a-2;i--){
if(sum/(i+1.0)==ans){
int x=count(v.begin(),v.end(), v[i]);
if(x!=1){
int count=0;
for(int j=i;j>=0;j--){
if(v[j]==v[i]) count++;
else break;
}
ans2+=C[x][count];
}else{
ans2++;
}
}
sum-=v[i];
}
cout<<precision(20);
cout<<ans<<endl<<ans2<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:54:9: error: 'precision' was not declared in this scope
54 | cout<<precision(20);
| ^~~~~~~~~
|
s597112355 | p03776 | C++ | #include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define yes cout<<"yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define no cout<<"no"<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/
ull C[55][55];
void comb_table(int n){
rep(i,n+1){
rep(j,n+1){
if(j==0||j==i)C[i][j]=(ull)1;
else C[i][j]=C[i-1][j-1]+C[i-1][j];
}
}
}
int main(){
int n,a,b;
vll v;
map<ull,int>imp,mp;
cin>>n>>a>>b;
comb_table(n);
rep(i,n){
ll in;
cin>>in;
v.pb(in);
imp[in]++;
}
sort(all(v),greater<ll>());
ll ave=0;
rep(i,a){
ave+=v[i];
}
int pos=0,max_pos=0;
rep(i,n){
if(v[i]==v[a-1]){
pos++;
if(i<a)max_pos++;
}
}
ull cnt=0;
if(v[0]==v[a-1]){
REP(i,a,min(pos+1,b))cnt+=C[pos][i];
}else{
cnt+=C[pos][max_pos];
}
printf("%.10f\n",ave/(double)a);
cout<<cnt<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:62:3: error: 'cin' was not declared in this scope
62 | cin>>n>>a>>b;
| ^~~
a.cc:18:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
17 | #include <ctime>
+++ |+#include <iostream>
18 | #define INF 1000000000
a.cc:89:3: error: 'cout' was not declared in this scope
89 | cout<<cnt<<endl;
| ^~~~
a.cc:89:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:89:14: error: 'endl' was not declared in this scope
89 | cout<<cnt<<endl;
| ^~~~
a.cc:18:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
17 | #include <ctime>
+++ |+#include <ostream>
18 | #define INF 1000000000
|
s508735480 | p03776 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define yes cout<<"yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define no cout<<"no"<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/
ull C[55][55];
void comb_table(int n){
rep(i,n+1){
rep(j,n+1){
if(j==0||j==i)C[i][j]=(ull)1;
else C[i][j]=C[i-1][j-1]+C[i-1][j];
}
}
}
int main(){
int n,a,b;
vll v;
map<ull,int>imp,mp;
cin>>n>>a>>b;
comb_table(n);
rep(i,n){
ll in;
cin>>in;
v.pb(in);
imp[in]++;
}
sort(all(v),greater<ll>());
ll ave=0;
rep(i,a){
ave+=v[i];
}
int pos=0,max_pos=0;
rep(i,n){
if(v[i]==v[a-1]){
pos++;
if(i<a)max_pos++;
}
}
ull cnt=0;
if(v[0]==v[a-1]){
REP(i,a,pos+1)cnt+=C[pos][i];
}else{
cnt+=C[pos][max_pos];
}
printf("%.10f\n",ave/(double)a);
cout<<cnt<<endl;
return 0;
}
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
using namespace std;
#define rep(i,n) for(int i=0;i vi;
typedef vector vll;
typedef pair pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/
ull C[55][55];
void comb_table(int n){
rep(i,n+1){
rep(j,n+1){
if(j==0||j==i)C[i][j]=(ull)1;
else C[i][j]=C[i-1][j-1]+C[i-1][j];
}
}
}
int main(){
int n,a,b;
vll v;
mapimp,mp;
cin>>n>>a>>b;
comb_table(n);
rep(i,n){
ll in;
cin>>in;
v.pb(in);
imp[in]++;
}
sort(all(v),greater());
ll ave=0;
rep(i,a){
ave+=v[i];
}
int pos=0,max_pos=0;
rep(i,n){
if(v[i]==v[a-1]){
pos++;
if(i#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define yes cout<<"yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define no cout<<"no"<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/
ull C[55][55];
void comb_table(int n){
rep(i,n+1){
rep(j,n+1){
if(j==0||j==i)C[i][j]=(ull)1;
else C[i][j]=C[i-1][j-1]+C[i-1][j];
}
}
}
int main(){
int n,a,b;
vll v;
map<ull,int>imp,mp;
cin>>n>>a>>b;
comb_table(n);
rep(i,n){
ll in;
cin>>in;
v.pb(in);
imp[in]++;
}
sort(all(v),greater<ll>());
ll ave=0;
rep(i,a){
ave+=v[i];
}
int pos=0,max_pos=0;
rep(i,n){
if(v[i]==v[a-1]){
pos++;
if(i<a)max_pos++;
}
}
ull cnt=0;
if(v[0]==v[a-1]){
REP(i,a,min(pos+1,b))cnt+=C[pos][i];
}else{
cnt+=C[pos][max_pos];
}
printf("%.10f\n",ave/(double)a);
cout<<cnt<<endl;
return 0;
}
| a.cc:93:10: error: #include expects "FILENAME" or <FILENAME>
93 | #include
| ^
a.cc:94:10: error: #include expects "FILENAME" or <FILENAME>
94 | #include
| ^
a.cc:95:10: error: #include expects "FILENAME" or <FILENAME>
95 | #include
| ^
a.cc:96:10: error: #include expects "FILENAME" or <FILENAME>
96 | #include
| ^
a.cc:97:10: error: #include expects "FILENAME" or <FILENAME>
97 | #include
| ^
a.cc:98:10: error: #include expects "FILENAME" or <FILENAME>
98 | #include
| ^
a.cc:99:10: error: #include expects "FILENAME" or <FILENAME>
99 | #include
| ^
a.cc:100:10: error: #include expects "FILENAME" or <FILENAME>
100 | #include
| ^
a.cc:101:10: error: #include expects "FILENAME" or <FILENAME>
101 | #include
| ^
a.cc:102:10: error: #include expects "FILENAME" or <FILENAME>
102 | #include
| ^
a.cc:103:10: error: #include expects "FILENAME" or <FILENAME>
103 | #include
| ^
a.cc:104:10: error: #include expects "FILENAME" or <FILENAME>
104 | #include
| ^
a.cc:105:10: error: #include expects "FILENAME" or <FILENAME>
105 | #include
| ^
a.cc:106:10: error: #include expects "FILENAME" or <FILENAME>
106 | #include
| ^
a.cc:107:10: error: #include expects "FILENAME" or <FILENAME>
107 | #include
| ^
a.cc:108:10: error: #include expects "FILENAME" or <FILENAME>
108 | #include
| ^
a.cc:109:10: error: #include expects "FILENAME" or <FILENAME>
109 | #include
| ^
a.cc:110:10: error: #include expects "FILENAME" or <FILENAME>
110 | #include
| ^
a.cc:116:9: warning: "rep" redefined
116 | #define rep(i,n) for(int i=0;i vi;
| ^~~
a.cc:24:9: note: this is the location of the previous definition
24 | #define rep(i,n) for(int i=0;i<int(n);i++)
| ^~~
a.cc:157:11: error: stray '#' in program
157 | if(i#include <iostream>
| ^
a.cc:180:9: warning: "rep" redefined
180 | #define rep(i,n) for(int i=0;i<int(n);i++)
| ^~~
a.cc:116:9: note: this is the location of the previous definition
116 | #define rep(i,n) for(int i=0;i vi;
| ^~~
a.cc:117:9: error: typedef declared 'auto'
117 | typedef vector vll;
| ^~~~~~
a.cc:118:9: error: typedef declared 'auto'
118 | typedef pair pi;
| ^~~~
a.cc:120:5: error: redefinition of 'int dx [4]'
120 | int dx[4]={1,0,-1,0};
| ^~
a.cc:43:5: note: 'int dx [4]' previously defined here
43 | int dx[4]={1,0,-1,0};
| ^~
a.cc:121:5: error: redefinition of 'int dy [4]'
121 | int dy[4]={0,1,0,-1};
| ^~
a.cc:44:5: note: 'int dy [4]' previously defined here
44 | int dy[4]={0,1,0,-1};
| ^~
a.cc:122:6: error: redefinition of 'bool debug'
122 | bool debug=false;
| ^~~~~
a.cc:45:6: note: 'bool debug' previously defined here
45 | bool debug=false;
| ^~~~~
a.cc:126:5: error: redefinition of 'ull C [55][55]'
126 | ull C[55][55];
| ^
a.cc:49:5: note: 'ull C [55][55]' previously declared here
49 | ull C[55][55];
| ^
a.cc:127:6: error: redefinition of 'void comb_table(int)'
127 | void comb_table(int n){
| ^~~~~~~~~~
a.cc:50:6: note: 'void comb_table(int)' previously defined here
50 | void comb_table(int n){
| ^~~~~~~~~~
a.cc: In function 'void comb_table(int)':
a.cc:116:32: error: expected ';' before 'vi'
116 | #define rep(i,n) for(int i=0;i vi;
| ^~
a.cc:128:3: note: in expansion of macro 'rep'
128 | rep(i,n+1){
| ^~~
a.cc:116:34: error: expected primary-expression before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ^
a.cc:128:3: note: in expansion of macro 'rep'
128 | rep(i,n+1){
| ^~~
a.cc:116:34: error: expected ')' before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ~ ^
a.cc:128:3: note: in expansion of macro 'rep'
128 | rep(i,n+1){
| ^~~
a.cc:116:32: error: expected ';' before 'vi'
116 | #define rep(i,n) for(int i=0;i vi;
| ^~
a.cc:129:5: note: in expansion of macro 'rep'
129 | rep(j,n+1){
| ^~~
a.cc:116:34: error: expected primary-expression before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ^
a.cc:129:5: note: in expansion of macro 'rep'
129 | rep(j,n+1){
| ^~~
a.cc:116:34: error: expected ')' before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ~ ^
a.cc:129:5: note: in expansion of macro 'rep'
129 | rep(j,n+1){
| ^~~
a.cc:130:10: error: 'j' was not declared in this scope
130 | if(j==0||j==i)C[i][j]=(ull)1;
| ^
a.cc:130:19: error: 'i' was not declared in this scope
130 | if(j==0||j==i)C[i][j]=(ull)1;
| ^
a.cc: At global scope:
a.cc:136:5: error: redefinition of 'int main()'
136 | int main(){
| ^~~~
a.cc:59:5: note: 'int main()' previously defined here
59 | int main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:139:3: error: 'mapimp' was not declared in this scope
139 | mapimp,mp;
| ^~~~~~
a.cc:116:32: error: expected ';' before 'vi'
116 | #define rep(i,n) for(int i=0;i vi;
| ^~
a.cc:142:3: note: in expansion of macro 'rep'
142 | rep(i,n){
| ^~~
a.cc:116:34: error: expected primary-expression before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ^
a.cc:142:3: note: in expansion of macro 'rep'
142 | rep(i,n){
| ^~~
a.cc:116:34: error: expected ')' before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ~ ^
a.cc:142:3: note: in expansion of macro 'rep'
142 | rep(i,n){
| ^~~
a.cc:146:5: error: 'imp' was not declared in this scope; did you mean 'mp'?
146 | imp[in]++;
| ^~~
| mp
a.cc:116:32: error: expected ';' before 'vi'
116 | #define rep(i,n) for(int i=0;i vi;
| ^~
a.cc:150:3: note: in expansion of macro 'rep'
150 | rep(i,a){
| ^~~
a.cc:116:34: error: expected primary-expression before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ^
a.cc:150:3: note: in expansion of macro 'rep'
150 | rep(i,a){
| ^~~
a.cc:116:34: error: expected ')' before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ~ ^
a.cc:150:3: note: in expansion of macro 'rep'
150 | rep(i,a){
| ^~~
a.cc:151:12: error: 'i' was not declared in this scope
151 | ave+=v[i];
| ^
a.cc:116:32: error: expected ';' before 'vi'
116 | #define rep(i,n) for(int i=0;i vi;
| ^~
a.cc:154:3: note: in expansion of macro 'rep'
154 | rep(i,n){
| ^~~
a.cc:116:34: error: expected primary-expression before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ^
a.cc:154:3: note: in expansion of macro 'rep'
154 | rep(i,n){
| ^~~
a.cc:116:34: error: expected ')' before ';' token
116 | #define rep(i,n) for(int i=0;i vi;
| ~ ^
a.cc:154:3: note: in expansion of macro 'rep'
154 | rep(i,n){
| ^~~
a.cc:155:10: error: 'i' was not declared in this scope
155 | if(v[i]==v[a-1]){
| ^
a.cc:157:11: error: expected ';' before 'include'
157 | if(i#include <iostream>
| ^~~~~~~~
| ;
a.cc:193:1: error: 'typedef' invalid in condition
193 | typedef long long ll;
| ^~~~~~~
a.cc:193:19: error: typedef 'll' is initialized (use 'decltype' instead)
193 | typedef long long ll;
| ^~
a.cc:193:21: error: expected initializer before ';' token
193 | typedef long long ll;
| ^
a.cc:193:21: error: expected ')' before ';' token
193 | typedef long long ll;
| ^
| )
a.cc:157:9: note: to match this '('
157 | if(i#include <iostream>
| ^
a.cc:206:23: error: a function-definition is not allowed here before '{' token
206 | void comb_table(int n){
| ^
a.cc:215:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
215 | int main(){
| ^~
a.cc:215:9: note: remove parentheses to default-initialize a variable
215 | int main(){
| ^~
| --
a.cc:215:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:215:11: error: a function-definition is not allowed here before '{' token
215 | int main(){
| ^
a.cc:248:2: error: expected '}' at end of input
248 | }
| ^
a.cc:155:21: note: to match this '{'
155 | if(v[i]==v[a-1]){
| ^
a.cc:248:2: error: expected '}' at end of input
248 | }
| ^
a.cc:154:11: note: to match this '{'
154 | rep(i,n){
| ^
a.cc:248:2: error: expected '}' at end of input
248 | }
| ^
a.cc:136:11: note: to match this '{'
136 | int main(){
| ^
|
s218176249 | p03776 | C++ | #include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;
using std::min;
using std::max;
using std::sort;
using std::abs;
typedef long long ll;
ll comb(ll n, ll r) {
if(n <= r){
return 1;
}
if(r == 0){
return 1;
}
return comb(n - 1, r - 1) + comb(n - 1, r);
}
int main(void) {
int n, a, b;
cin >> n >> a >> b;
vector<ll> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
sort(v.begin(), v.end());
vector<ll> acc(v); // sum of [i, n)
for (int i = n - 1; i > 0; i--) {
acc[i - 1] += acc[i];
}
ll opt_num = -1;
for (int i = a; i <= b; i++) {
if (opt_num == -1 || acc[n - i] * opt_num > acc[n - opt_num] * i) {
opt_num = i;
}
}
cout << std::fixed << std::setprecision(8);
cout << (1.0 * acc[n - opt_num] / opt_num) << endl;
ll cnt = 0;
for (int i = a; i <= b; i++) {
if (acc[n - i] * opt_num != acc[n - opt_num] * i) {
continue;
}
ll key = v[n - i];
ll cntIn = 0;
for (int j = n - i; j < n; j++) {
if (v[j] == key) {
cntIn++;
}
}
ll cntOut = 0;
for (int j = 0; j < n - i; j++) {
if (v[j] == key) {
cntOut++;
}
}
cnt += comb(cntIn + cntOut, cntIn);
}
cout << cnt << endl;
return 0;
| a.cc: In function 'int main()':
a.cc:90:14: error: expected '}' at end of input
90 | return 0;
| ^
a.cc:40:16: note: to match this '{'
40 | int main(void) {
| ^
|
s409215660 | p03776 | C++ | #include <iostream>
#include <vector>
using namespace std;
long long combi[50][50];
long long combination(int n, int r) {
if (n/2 < r) {
r = n - r;
}
if (combi[n][r] != 0) return combi[n][r];
if (n == r || r == 0) return 1;
return combi[n][r] = combination(n-1, r) + combination(n-1, r-1);
}
int main() {
int N, A, B;
cin >> N >> A >> B;
vector<long long> v(N);
for (int i = 0; i < N; i++)
cin >> v[i];
sort(v.begin(), v.end(), greater<int>());
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
combi[i][j] = 0;
int n1 = 0, n2 = 0;
long long sum = 0;
for (int i = 0; i < N; i++) {
if (i < A) sum += v[i];
if (v[i] == v[A-1]) n1++;
else if (v[i] > v[A-1]) n2++;
}
double avg = (double)sum / A;
long long num = 0;
if (v[A-1] == v[0]) {
for (int r = A - n2; r <= B && r <= n1; r++)
num += combination(n1, r);
} else {
num = combination(n1, A - n2);
}
printf("%.6f\n%lld\n", avg, num);
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:3: error: 'sort' was not declared in this scope; did you mean 'short'?
24 | sort(v.begin(), v.end(), greater<int>());
| ^~~~
| short
|
s891299100 | p03776 | C++ | #include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define EPS 1e-6
#define INF 2147483647
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define llINF 9223372036854775807
using namespace std;
int main(){
int n,a,b;
cin>>n>>a>>b;
vector<ll>vl;
for(int i=0;i<n;i++){
ll aaaaaa;cin>>aaaaaa;
vl.pb(aaaaaa);
}
sort(vl.begin(),vl.end(),greater<ll>());
double ma=0;
for(int i=0;i<a;i++)
ma+=vl[i];
printf("%.7f\n",ma/(double)a);
ll acnt=0;
ll apointer=0;
for(int i=0;i<n;i++){
if(vl[i]==vl[a-1]&&acnt==0){
apointer=i;acnt++;
}else if(vl[i]==vl[a-1])acnt++;
}
ll cnt=0;
if(acnt==1)cnt=1;
else if(acnt==n){
for(int i=a-1;i<b;i++){
cnt+=(ll)1<<i;
}
}else if(apointer==0&&acnt!=n){
ll aaacnt=1;
for(int i=a;i<=acnt&&i<=b;i++){
aaacnt=1;
int abc=min(i-pointer,min(acnt,b)-(i-apointer));
for(int j=0;j<abc;j++){
aaacnt*=(ll)(acnt-j);
}
for(int j=1;j<=abc;j++)
aaacnt=(ll)aaacnt/j;
cnt+=aaacnt;
}
}else{
cnt=1;
int abc=min(a-apointer,acnt-(a-apointer));
for(int i=0;i<abc;i++){
cnt*=(ll)(acnt-i);
}
for(int i=1;i<=abc;i++){
cnt=(ll)cnt/i;
}
}
cout<<cnt<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:50:21: error: 'pointer' was not declared in this scope; did you mean 'apointer'?
50 | int abc=min(i-pointer,min(acnt,b)-(i-apointer));
| ^~~~~~~
| apointer
a.cc:50:32: error: no matching function for call to 'min(long long int&, int&)'
50 | int abc=min(i-pointer,min(acnt,b)-(i-apointer));
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:50:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
50 | int abc=min(i-pointer,min(acnt,b)-(i-apointer));
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:50:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
50 | int abc=min(i-pointer,min(acnt,b)-(i-apointer));
| ~~~^~~~~~~~
|
s365748137 | p03776 | C++ | #include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define EPS 1e-6
#define INF 2147483647
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define llINF 9223372036854775807
using namespace std;
int main(){
int n,a,b;
cin>>n>>a>>b;
vector<ll>vl;
for(int i=0;i<n;i++){
ll aaaaaa;cin>>aaaaaa;
vl.pb(aaaaaa);
}
sort(vl.begin(),vl.end(),greater<ll>());
double ma=0;
for(int i=0;i<a;i++)
ma+=vl[i];
printf("%.7f\n",ma/(double)a);
ll acnt=0;
ll apointer=0;
for(int i=0;i<n;i++){
if(vl[i]==vl[a-1]&&acnt==0){
apointer=i;acnt++;
}else if(vl[i]==vl[a-1])acnt++;
}
ll cnt=0;
if(acnt==1)cnt=1;
else if(acnt==n){
for(int i=a-1;i<b;i++){
cnt+=(ll)1<<i;
}
}else if(apointer==0&&acnt!=n){
ll aaacnt=1;
for(int i=a;i<=acnt&&i<=b;i++){
aaacnt=1;
int abc=min(i-pointer,min(acnt,b)-(i-pointer));
for(int j=0;j<abc;j++){
aaacnt*=(ll)(acnt-j);
}
for(int j=1;j<=abc;j++)
aaacnt=(ll)aaacnt/j;
cnt+=aaacnt;
}
}else{
cnt=1;
int abc=min(a-apointer,acnt-(a-apointer));
for(int i=0;i<abc;i++){
cnt*=(ll)(acnt-i);
}
for(int i=1;i<=abc;i++){
cnt=(ll)cnt/i;
}
}
cout<<cnt<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:50:21: error: 'pointer' was not declared in this scope; did you mean 'apointer'?
50 | int abc=min(i-pointer,min(acnt,b)-(i-pointer));
| ^~~~~~~
| apointer
a.cc:50:32: error: no matching function for call to 'min(long long int&, int&)'
50 | int abc=min(i-pointer,min(acnt,b)-(i-pointer));
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:50:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
50 | int abc=min(i-pointer,min(acnt,b)-(i-pointer));
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:50:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
50 | int abc=min(i-pointer,min(acnt,b)-(i-pointer));
| ~~~^~~~~~~~
|
s221541201 | p03776 | C++ | #include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll c[51][51];
void comb_table(int n) {
for (int i = 0; i <= n; i++) {
c[i][0] = 1LL;
c[i][i] = 1LL;
for (int j = 1; j < i; j++) {
c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
}
}
}
int main(void) {
int n, a, b;
cin >> n >> a >> b;
vector<ll> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
sort(v.begin(), v.end(), greater<int>());
double sum = 0.0;
for (int i = 0; i < a; i++) {
sum += v[i];
}
cout.precision(20);
cout << sum / a << endl;
int cnt1 = 0, cnt2 = 0;
for (int i = 0; i < n; i++) {
if (v[i] == v[a - 1]) {
cnt1++;
if (i < a) {
cnt2++;
}
}
}
comb_table(n);
ll ans = 0LL;
if (cnt2 != a) {
ans = c[cnt1][cnt2];
} else {
for (int i = a; i <= b; i++) {
ans += c[cnt1][i];
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:3: error: 'sort' was not declared in this scope; did you mean 'short'?
22 | sort(v.begin(), v.end(), greater<int>());
| ^~~~
| short
|
s568537282 | p03776 | C++ | #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
int cmp(long long a,long long b){
return a>b;
}
long long C(long long a,long long b){
long long ans=1;
for(int i=1;i<=a;i++){
ans*=(b-i+1);ans/=i;
}
return ans;
}
int n;
long long a,b;
long long s[100001];
int main()
{
scanf("%d%lld%lld",&n,&a,&b);
for(int i=1;i<=n;i++){
scanf("%lld",&s[i]);
}
sort(s+1,s+n+1,cmp);
if(s[1]==s[a]){
cout<<s[1]<<endl;
int t=0;
long long ans=0;
s[n+1]=s[1]+1;
for(int i=1;i<=n+1;i++){
if(s[i]!=s[1]){
t=i-1;
break;
}
}
for(int i=a;i<=min(b,t);i++){
ans+=C(t-i,t);
}
}
else {
double ans=0;
for(int i=1;i<=a;i++){
ans+=a[i];
}
ans/=a;
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:27: error: no matching function for call to 'min(long long int&, int&)'
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:39:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:39:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
a.cc:47:21: error: invalid types 'long long int[int]' for array subscript
47 | ans+=a[i];
| ^
|
s957095396 | p03776 | C++ | #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
int cmp(long long a,long long b){
return a>b;
}
long long C(long long a,long long b){
long long ans=1;
for(int i=1;i<=a;i++){
ans*=(b-i+1);ans/=i;
}
return ans;
}
int n;
long long a,b;
long long s[100001];
int main()
{
scanf("%d%lld%lld",&n,&a,&b);
for(int i=1;i<=n;i++){
scanf("%lld",&s[i]);
}
sort(s+1,s+n+1,cmp);
if(s[1]==s[a]){
cout<<s[1]<<endl;
int t=0;
long long ans=0;
s[n+1]=s[1]+1;
for(int i=1;i<=n+1;i++){
if(s[i]!=s[1]){
t=i-1;
break;
}
}
for(int i=a;i<=min(b,t);i++){
ans+=C(t-i,t);
}
}
else {
double ans=0;
for(int i=1;i<=a;i++){
ans+=a[i];
}
ans/=a;
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:27: error: no matching function for call to 'min(long long int&, int&)'
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:39:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:39:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
a.cc:47:21: error: invalid types 'long long int[int]' for array subscript
47 | ans+=a[i];
| ^
|
s681061013 | p03776 | C++ | #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
int cmp(long long a,long long b){
return a>b;
}
long long C(long long a,long long b){
long long ans=1;
for(int i=1;i<=a;i++){
ans*=(b-i+1);ans/=i;
}
return ans;
}
int n;
long long a,b;
long long s[100001];
int main()
{
scanf("%d%lld%lld",&n,&a,&b);
for(int i=1;i<=n;i++){
scanf("%lld",&s[i]);
}
sort(s+1,s+n+1,cmp);
if(s[1]==s[a]){
cout<<s[1]<<endl;
int t=0;
long long ans=0;
s[n+1]=s[1]+1;
for(int i=1;i<=n+1;i++){
if(s[i]!=s[1]){
t=i-1;
break;
}
}
for(int i=a;i<=min(b,t);i++){
ans+=C(t-i,t);
}
}
else {
double ans=0;
for(int i=1;i<=a;i++){
ans+=a[i];
}
ans/=a;
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:27: error: no matching function for call to 'min(long long int&, int&)'
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:39:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:39:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
39 | for(int i=a;i<=min(b,t);i++){
| ~~~^~~~~
a.cc:47:21: error: invalid types 'long long int[int]' for array subscript
47 | ans+=a[i];
| ^
|
s683870770 | p03776 | C++ | // I/O
#include <iostream>
#include <iomanip>
// data structures
#include <set>
#include <queue>
#include <vector>
// manipulations
#include <algorithm>
#define rep(i,n) for(int i=0;i< (n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define for_lowercase(c) for(int c='a';c<='z';++c)
#define for_uppercase(c) for(int c='A';c<='Z';++c)
#define ALL(a) (a).begin(),(a).end()
using LLI = long long int;
LLI GCD(LLI a,LLI b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LLI LCM(LLI a,LLI b){ return (a/GCD(a,b))*b; }
using VI = std::vector<LLI>;
using PI = std::pair<LLI,LLI>;
using VVI = std::vector<VI>;
using VPI = std::vector<PI>;
template<class T> bool is_odd (T x){ return x%2 ; }
template<class T> bool is_even(T x){ return !(x%2); }
LLI combination(LLI n,LLI k,bool reset=false){
static VVI C; static LLI n_hashed = -1;
if(n<0){ std::cerr << "[ERROR] n must be non-negative in combination()" << std::end; exit(1); }
if(!(0<=k&&k<=n)){ std::cerr << "[WARNING] k should be in range [0,n] in combination()" << std::endl; return 0; }
if(n_hashed<n || reset){
C.resize(n+1);
for(int i=0;i<=n;++i) C[i].resize(i+1,1); // filled with 1
for(int i=1;i<=n;++i)for(int j=1;j<i;++j) C[i][j] = C[i-1][j-1] + C[i-1][j]; // calc
n_hashed = n;
}
return C[n][k];
}
int main() {
std::ios::sync_with_stdio(false);
LLI N,A,B;
std::cin >> N >> A >> B;
VI v(N);
rep(i,N)
std::cin >> v[i];
std::sort(ALL(v),std::greater<LLI>()); // descending order
double max_average = 0.;
rep(i,A){
max_average += v[i];
}
max_average /= A;
std::cout << std::fixed << std::setprecision(6) << max_average << std::endl;
LLI min = v[A-1];
LLI num_min = 0;
rep(i,N)
if(v[i]==min)
++num_min;
LLI num_fixed;
for(num_fixed=0;v[num_fixed]>min;++num_fixed);
A -= num_fixed;
B -= num_fixed;
// sum of (num_min choose i) for i in [A,B]
LLI result = 0;
for(int i=A;i<=std::min(B,num_min);++i){
result += combination(num_min,i);
if(min!=v[0]) break;
}
std::cout << result << std::endl;
return 0;
} | a.cc: In function 'LLI combination(LLI, LLI, bool)':
a.cc:29:77: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')
29 | if(n<0){ std::cerr << "[ERROR] n must be non-negative in combination()" << std::end; exit(1); }
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
/usr/include/c++/14/ostream:306 |
s635501499 | p03776 | C++ | #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif
//改造
typedef long long int ll;
using namespace std;
//ここから編集する
#define MAX_PAS 50 //最大の第一引数
ll pascal[MAX_PAS + 1][MAX_PAS + 1];
void calcPascal() {
REP(i, 1, MAX_PAS + 1) {
pascal[i][i] = 1;
pascal[i][0] = 1;
}
REP(i, 1, MAX_PAS + 1) {
REP(j, 1, i) {
if (pascal[i][j] == 0)pascal[i][j] = pascal[i - 1][j - 1] + pascal[i - 1][j];
}
}
}
ll nCr(int n,int r){
if(pascal[n][r] != 0) return pascal[n][r];
if(n == 0 || n == r) return 1;
return nCr(n-1,r-1) + nCr(n-1,r);
}
int main() {
calcPascal();
int A;
int B;
int N;
ll selects = 0;
cin >> N >> A >> B;
vector<ll> v(N);
REP(i, 0, N) {
cin >> v[i];
}
sort(v.begin(), v.end(), greater<ll>());
double ave;
while (v[A - 1] != v[B - 1]) {
B--;
}
if (v[A - 1] == v[0]) {
ave = (double) v[0];
REP(i, A, B + 1) {
// selects += pascal[B][i];
selects += nCr[B][i];
}
} else {
ll sum_v = 0;
int M = 0;
REP(i, 0, A) {
sum_v += v[i];
}
REP(i, 0, N) {
if (v[i] == v[A - 1]) {
M++;
}
}
ave = (double) sum_v / A;
int begin = A - 1;
while (v[begin] == v[A - 1] && begin >= 0) {
begin--;
}
// selects = pascal[M][A - 1 - begin];
selects = nCr(M,A-1-begin);
}
cout << fixed << setprecision(7) << ave << endl;
cout << selects << endl;
}
| a.cc: In function 'int main()':
a.cc:109:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
109 | selects += nCr[B][i];
| ^
a.cc:109:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
109 | selects += nCr[B][i];
| ^
a.cc:109:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
109 | selects += nCr[B][i];
| ~~~~~~~~^~~~~~~~~~~~
a.cc:109:21: error: invalid conversion from 'll (*)(int, int)' {aka 'long long int (*)(int, int)'} to 'll' {aka 'long long int'} [-fpermissive]
109 | selects += nCr[B][i];
| ~~~~~~~~^~~~~~~~~~~~
| |
| ll (*)(int, int) {aka long long int (*)(int, int)}
|
s755194971 | p03776 | C++ | #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define INF 900000000
#define LINF 9000000000000000000
typedef long long ll;
typedef pair<int, int> P;
int n, a, b;
ll v[50];
ll dp[51][51];
int main(){
//cin.tie(0);
//ios::sync_with_stdio(false);
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 0; i <= n-a; i++) {
for (int j = 0; j < b; j++) {
cout << i << ' ' << j << ' ' << dp[i][j+1] << ' ' << v[i+j] << endl;
if (i+j >= n) break;
dp[i][j+1] = max(dp[i][j+1], dp[i][j]+v[i+j]);
}
}
for (int i = 0; i < n; i++) {
for (int j = 1; j <= b; j++) {
cout << dp[i][j] << ' ';
}
cout << endl;
}
double ans = 0;
int cnt = 0;
for (int i = a; i <= b; i++) {
double avr = dp[n-a+1][i] / i;
cout << "avr " << avr << " "
if (ans == avr) cnt++;
else if (ans < avr) {
cnt = 1;
ans = avr;
}
}
printf("%.6f\n", ans);
cout << cnt << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:45: error: expected ';' before 'if'
43 | cout << "avr " << avr << " "
| ^
| ;
44 | if (ans == avr) cnt++;
| ~~
a.cc:45:17: error: 'else' without a previous 'if'
45 | else if (ans < avr) {
| ^~~~
|
s384959930 | p03776 | C++ | #include <iostream>
#include <vector>
using namespace std;
//1
//1 1
//1 2 1
//1 3 3 1
//1 4 6 4 1
//
//aC0 = 1
//aCa = 1
//aCb = a-1Cb + a-1Cb-1
//2C1 = 1C1 + 1C0
int main(){
int N, A, B;
cin >> N >> A >> B;
vector<long long> v(N);
for(int i=0; i<N; i++) cin >> v[i];
sort(v.begin(), v.end(), greater<long long>());
long long ans = 0;
for(int i=0; i<A; i++) ans += v[i];
cout << static_cast<double>(ans) / A << endl;
long long comb[100][100];
for(int i=0; i<=50; i++){
comb[i][0] = 1;
comb[i][i] = 1;
}
for(int i=1; i<=50; i++)
for(int j=1; j<i; j++)
comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
int cnt1 = 0, cnt2 = 0;
if(v[0] != v[A-1]){
for(int i=0; i<A; i++)
if(v[i] == v[A-1])
cnt1++;
for(int i=0; i<N; i++)
if(v[i] == v[A-1])
cnt2++;
cout << comb[cnt2][cnt1] << endl;
return 0;
}else{
for(int i=0; i<N; i++)
if(v[i] == v[A-1])
cnt2++;
long long num = 0;
for(int i=A; i<=B; i++)
num += comb[cnt2][i];
cout << num << endl;
return 0;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'short'?
22 | sort(v.begin(), v.end(), greater<long long>());
| ^~~~
| short
|
s836582964 | p03776 | C++ | using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Program {
class MainClass {
////////////////////////////////////////////////////////////
int N, A, B;
long[] v;
void Solve() {
io.i(out N, out A, out B);
io.ini(out v, N);
Mat mat = new Mat();
var C = mat.C(50);
v.SortR();
double maxAve = 0;
A.REP(i => maxAve += v[i]);
maxAve /= A;
long ans = 0;
var top = v.First();
var bot = v[A - 1];
if (top != bot) {
var indexedV = v.Select((e, i) => new { e, i });
var choice = indexedV.Where(v => v.e == bot).Count();
var choiced = indexedV.Where(v => v.e == bot && v.i < A).Count();
ans = C[choice, choiced];
} else {
var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
for (int i = A; i <= B; i++) {
if (choice < i) break;
ans += C[choice, i];
}
}
io.o(maxAve);
io.o(ans);
}
////////////////////////////////////////////////////////////
public static void Main() { new MainClass().Stream(); }
IO io = new IO();
void Stream() { Solve(); io.writeFlush(); }
//void Stream() { Test(); io.writeFlush(); }
void Test() { }
#region MockMacro
//cannot use break,continue,goto
void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
#endregion
////////////////////////////////////////////////////////////
}
#region default
class IO {
TYPE tp;
string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); tp = new TYPE(); }
public string Next() {
if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "") st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public string String => Next();
public char Char => char.Parse(String);
public int Int => int.Parse(String);
public long Long => long.Parse(String);
public double Double => double.Parse(String);
public string[] arr => Console.ReadLine().Split(' ');
public char[] arrChar => Array.ConvertAll(arr, char.Parse);
public int[] arrInt => Array.ConvertAll(arr, int.Parse);
public long[] arrLong => Array.ConvertAll(arr, long.Parse);
public double[] arrDouble => Array.ConvertAll(arr, double.Parse);
public T i<T>() { return tp.suitType<T>(String); }
public void i<T>(out T v) { v = tp.suitType<T>(String); }
public void i<T, U>(out T v1, out U v2) { i(out v1); i(out v2); }
public void i<T, U, V>(out T v1, out U v2, out V v3) { i(out v1); i(out v2); i(out v3); }
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
i(out v1); i(out v2); i(out v3); i(out v4);
}
public void i<T, U, V, W, X>(out T v1, out U v2, out V v3, out W v4, out X v5) {
i(out v1); i(out v2); i(out v3); i(out v4); i(out v5);
}
public void ini<T>(out T[] a, int n) { a = new T[n]; for (int i = 0; i < n; i++) a[i] = tp.suitType<T>(String); }
public void ini<T, U>(out T[] a, out U[] b, int n) {
a = new T[n]; b = new U[n]; for (int i = 0; i < n; i++) { a[i] = i<T>(); b[i] = i<U>(); }
}
public void ini<T, U, V>(out T[] a, out U[] b, out V[] c, int n) {
a = new T[n]; b = new U[n]; c = new V[n];
for (int i = 0; i < n; i++) { a[i] = i<T>(); b[i] = i<U>(); c[i] = i<V>(); }
}
public void ini<T>(out T[,] a, int h, int w) {
a = new T[h, w]; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) a[i, j] = i<T>();
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) { Array.ForEach(a, n => o(n)); }
public void o<T>(T[,] a) { a.GetLength(0).REP(i => { a.GetLength(1).REP(j => or(a[i, j] + " ")); br(); }); }
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) { o(connect<T>(a)); }
public void or<T>(T a) { Console.Write(a); }
public void br() { o(""); }
public void writeFlush() { Console.Out.Flush(); }
private string connect<T>(params T[] s) { return string.Join(" ", s); }
}
class TYPE {
public bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
public T convertType<T, U>(U v) { return (T)Convert.ChangeType(v, typeof(T)); }
public T suitType<T>(string s) {
if (typeEQ<T, int>()) return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>()) return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>()) return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>()) return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
}
class PQueue<T> where T : IComparable {
public List<T> heap; private Comparison<T> comp; private IComparer<T> comparer;
private int size; private int type;//type=0->min
public PQueue(int type = 0) : this(Comparer<T>.Default) { this.type = type; }
public PQueue(IComparer<T> comparer) : this(16, comparer.Compare) { this.comparer = comparer; }
public PQueue(Comparison<T> comparison) : this(16, comparison) { }
public PQueue(int capacity, Comparison<T> comparison) { this.heap = new List<T>(capacity); this.comp = comparison; }
public void Enqueue(T item) {
this.heap.Add(item); var i = size++;
while (i > 0) { var p = (i - 1) >> 1; if (Compare(this.heap[p], item) <= 0) break; this.heap[i] = heap[p]; i = p; }
this.heap[i] = item;
}
public T Dequeue() {
var ret = this.heap[0]; var x = this.heap[--size]; var i = 0;
while ((i << 1) + 1 < size) {
var a = (i << 1) + 1; var b = (i << 1) + 2; if (b < size && Compare(heap[b], heap[a]) < 0) a = b;
if (Compare(heap[a], x) >= 0) break; heap[i] = heap[a]; i = a;
}
heap[i] = x; heap.RemoveAt(size);
return ret;
}
public T Peek() { return heap[0]; }
public int Count { get { return size; } }
public bool Any() { return size > 0; }
public bool Empty() { return !Any(); }
public bool Contains(T v) { return heap.Contains(v); }
private int Compare(T x, T y) { return type == 0 ? x.CompareTo(y) : y.CompareTo(x); }
}
#endregion
#region other
class Mat {
public long mod = 1000000007;//10^9+7
public long Pow(long a, long b) {
if (b == 0) return 1;
if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) { long ret = 1; for (long i = 1; i <= n; i++) ret = (ret * i) % mod; return ret; }
public long ModC(long n, long r) {
if (r == 0 || n == r) return 1;
if (n == 0) return 0;
if (n < 0 || n < r) throw new ArgumentException("n,r invalid");
else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
}
public long[,] C(int N) {
long[,] Co = new long[N + 1, N + 1];
(N + 1).REP(i => (i + 1).REP(j => Co[i, j] = (j == 0 || j == i) ? 1L : Co[i - 1, j - 1] + Co[i - 1, j]));
return Co;
}
public long DupC(long n, long r) { return ModC(n + r - 1, r); }
public long P(long n, long r) { return Fact(n) / (Fact(n - r)); }//test
public bool isPrime(long n) {
if (n == 2) return true; if (n < 2 || n % 2 == 0) return false;
for (long v = 3; v <= (long)Math.Sqrt(n); v += 2) if (n % v == 0) return false;
return true;
}
public long LCM(long a, long b) { return a * (b / GCD(a, b)); }
public long LCM(params long[] a) { return a.Aggregate((v, n) => LCM(v, n)); }
public long GCD(long a, long b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
public long GCD(params long[] array) { return array.Aggregate((v, n) => GCD(v, n)); }
public T Max<T>(params T[] a) { return a.Max(); }
public T Min<T>(params T[] a) { return a.Min(); }
public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
public double Dis(int x1, int y1, int x2, int y2) { return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)); }
public int mDis(int x1, int y1, int x2, int y2) { return Math.Abs(x1 - x2) + Math.Abs(y1 - y2); }
public int[] DigArr(int n) { int[] ret = new int[Digit(n)]; ret.Length.REP(i => ret[i] = DigVal(n, i + 1)); return ret; }
public long DigArr2Num(IEnumerable<int> enu) { return enu.Aggregate((v, n) => v * 10 + n); }
public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; }
public int DigVal(int n, int dig) { return (n % (int)Pow(10, dig)) / (int)Pow(10, dig - 1); }
public long Tousa(long a, long d, long n) { return a + (n - 1) * d; }
public long TousaSum(long a, long d, long n) { return n * (2 * a + (n - 1) * d) / 2; }
public long[] enuDivsor(long N) {
var ret = new SortedSet<long>();
for (long i = 1; i * i <= N; i++)
if (N % i == 0) { ret.Add(i); ret.Add(N / i); }
return ret.ToArray();
}
public IEnumerable<int[]> enuP(int[] Arr, int Use = -1) {//列挙順列
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0 || Arr.Length < Use) yield break;
var s = new Stack<List<int>>();
Arr.Length.REPR(i => s.Push(new List<int>() { i }));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Count == Use) {
var ret = new List<int>(); cur.ForEach(X => ret.Add(Arr[X]));
yield return ret.ToArray();
} else
Arr.Length.REPR(i => { if (!cur.Contains(i)) s.Push(new List<int>(cur) { i }); });
}
}
public IEnumerable<int[]> enuC(int[] Arr, int Use = -1) {//列挙組み合わせ
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0 || Arr.Length < Use) yield break;
var s = new Stack<Tuple<int, List<int>>>();
Arr.Length.REPR(i => s.Push(Tuple.Create(i, new List<int>() { Arr[i] })));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item2.Count == Use) yield return cur.Item2.ToArray();
else for (int i = Arr.GetUpperBound(0); i > cur.Item1; i--)
s.Push(Tuple.Create(i, new List<int>(cur.Item2) { Arr[i] }));
}
}
public IEnumerable<int[]> enuDupP(int[] Arr, int Use = -1) {//列挙重複順列
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0) yield break; var s = new Stack<List<int>>();
Arr.Length.REPR(i => s.Push(new List<int>() { Arr[i] }));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Count == Use) yield return cur.ToArray();
else Arr.Length.REPR(i => s.Push(new List<int>(cur) { Arr[i] }));
}
}
public IEnumerable<int[]> enuDupC(int[] Arr, int Use = -1) {//列挙組み合わせ
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0) yield break;
var s = new Stack<Tuple<int, List<int>>>();
Arr.Length.REPR(i => s.Push(Tuple.Create(i, new List<int>() { Arr[i] })));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item2.Count == Use) yield return cur.Item2.ToArray();
else for (int i = Arr.GetUpperBound(0); i >= cur.Item1; i--)
s.Push(Tuple.Create(i, new List<int>(cur.Item2) { Arr[i] }));
}
}
public IEnumerable<long[]> enuPart(string str) {
var s = new Stack<Tuple<string, List<long>, int>>();
s.Push(Tuple.Create(str[0].ToString(), new List<long>(), 1));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item3 >= str.Length) yield return (new List<long>(cur.Item2) { cur.Item1.toLong() }).ToArray();
else {
s.Push(Tuple.Create(cur.Item1 + str[cur.Item3], new List<long>(cur.Item2), cur.Item3 + 1));
s.Push(Tuple.Create(str[cur.Item3].ToString(), new List<long>(cur.Item2) { cur.Item1.toLong() }, cur.Item3 + 1));
}
}
}
}
class Time {
public int[] M = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
public int[] D = { 31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
public Time() { D[1] = 28; }
public Time(int y) { D[1] = isLeapYear(y) ? 29 : 28; }
public bool isLeapYear(int y) { return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)); }
}
#endregion
#region Data
class AssociativeArray<T> : IEnumerable {
public Dictionary<T, int> dic;
public AssociativeArray() { dic = new Dictionary<T, int>(); }
public AssociativeArray(params T[] a) { dic = new Dictionary<T, int>(); Add(a); }
public void Add(T a) { if (!conK(a)) dic[a] = 0; dic[a]++; }
public void Add(params T[] a) { a.Length.REP(i => { if (!conK(a[i])) dic[a[i]] = 0; dic[a[i]]++; }); }
public void Set(T k, int v) { if (!dic.ContainsKey(k)) dic[k] = 0; dic[k] = v; }
public void Remove(params T[] a) { a.Length.REP(i => { if (conK(a[i])) dic.Remove(a[i]); }); }
public T[] Keys() { return dic.Keys.ToArray<T>(); }
public int Val(T k) { return (dic.ContainsKey(k)) ? dic[k] : 0; }
public int ValSum => dic.Values.Sum();
public int KeyNum => dic.Keys.Count;
public int MaxVal => dic.Values.Max();
public int MinVal => dic.Values.Min();
public T MaxKey => MaxK();
public T MinKey => MinK();
public T MaxK() { var maxV = MaxVal; return dic.First(d => d.Value == maxV).Key; }
public T MinK() { var minV = MinVal; return dic.First(d => d.Value == minV).Key; }
public bool conK(T k) { return dic.ContainsKey(k); }
public bool anyK(params T[] k) { return k.Any(key => conK(key)); }
public bool allK(params T[] k) { return k.All(key => conK(key)); }
public void Show() { foreach (var v in dic) { Console.WriteLine(v.Key + " : " + v.Value); } }
public IEnumerator GetEnumerator() { foreach (var kp in dic) yield return kp; }
public T[] ValueSortedKey(bool inc = true) {//test
return (inc ? (dic.OrderBy(kp => kp.Value)) : (dic.OrderByDescending(kp => kp.Value)))
.ThenBy(kp => kp.Key).ToDictionary(kp => kp.Key, kp => kp.Value).Keys.ToArray();
}
//:sort->array
}
class Index {
public int[] Comp(int[] bef) {
int[] aft = new int[bef.Length];
var tmp = bef.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);
aft = bef.Select(v => tmp[v]).ToArray();
return aft;
}
}
class TreeDis {//TODO:shortestPath
public List<Tuple<long, long>>[] g; public long[] a2other; private int type;
public TreeDis(int type = 0) { this.type = type; }//0->bfs,other->dfs
public void Init(long n) { g = new List<Tuple<long, long>>[n + 1]; g.Length.REP(i => g[i] = new List<Tuple<long, long>>()); }
public void Run(long[] a, long[] b) { a.Length.REP(i => { g[a[i]].Add(Tuple.Create(b[i], 1L)); g[b[i]].Add(Tuple.Create(a[i], 1L)); }); }
public void Run(long[] a, long[] b, long[] w) { a.Length.REP(i => { g[a[i]].Add(Tuple.Create(b[i], w[i])); g[b[i]].Add(Tuple.Create(a[i], w[i])); }); }
public long[] a2iArr(long a) { a2other = new long[g.Count()]; if (type == 0) BFS(a); else DFS(a); return a2other; }
private void BFS(long a) {
var q = new Queue<Tuple<long, long>>(); q.Enqueue(Tuple.Create(a, -1L));
while (q.Count > 0) {
var c = q.Dequeue();
foreach (var v in g[c.Item1]) {
if (v.Item1 == c.Item2) continue;
a2other[v.Item1] = a2other[c.Item1] + v.Item2; q.Enqueue(Tuple.Create(v.Item1, c.Item1));
}
}
}
private void DFS(long a) {
var s = new Stack<Tuple<long, long>>(); s.Push(Tuple.Create(a, -1L));
while (s.Count > 0) {
var c = s.Pop();
foreach (var v in g[c.Item1]) {
if (v.Item1 == c.Item2) continue;
a2other[v.Item1] = a2other[c.Item1] + v.Item2; s.Push(Tuple.Create(v.Item1, c.Item1));
}
}
}
}
class ShortestPath {
public long INF = (long)1e15; protected int I = -1; protected int V; protected int E; public long[] cost;
public List<Tuple<int, long>>[] Adj; protected bool isNonDir = true;
public void Init(int n) { I = n + 1; V = n; Adj = new List<Tuple<int, long>>[I]; I.REP(i => Adj[i] = new List<Tuple<int, long>>()); }
public void AddPath(int f, int t, long c) {
E++;
if (isNonDir) {
Adj[f].Add(Tuple.Create(t, c)); Adj[t].Add(Tuple.Create(f, c));
} else {
Adj[f].Add(Tuple.Create(t, c));
}
}
public void AddPath(int[] f, int[] t, long[] c) { f.Length.REP(i => AddPath(f[i], t[i], c[i])); }
}
class Dijkstra : ShortestPath {//隣接対応後検証不足,有向とか
public long MinCost(int f, int t) {
cost = new long[I]; cost.Set(INF); cost[f] = 0;
var pq = new PQueue<Tuple<int, long>>(); pq.Enqueue(Tuple.Create(f, 0L));//(from,cost)
while (pq.Count > 0) {
var cur = pq.Dequeue();
if (cost[cur.Item1] < cur.Item2) continue; Adj[cur.Item1].Count.REP(i => {
var tmp = Adj[cur.Item1][i];
if (cost[tmp.Item1] > cost[cur.Item1] + tmp.Item2) {
cost[tmp.Item1] = cost[cur.Item1] + tmp.Item2; pq.Enqueue(Tuple.Create(tmp.Item1, cost[tmp.Item1]));
}
});
}
return cost[t];
}
}
class BellmanFord : ShortestPath {
private bool[] neg;
public BellmanFord() { }
public BellmanFord(bool isNonDir) { this.isNonDir = isNonDir; }
public long MinCost(int f, int t) {
cost = new long[I]; cost.Set(INF); cost[f] = 0; neg = new bool[I];
for (int i = 0; i < I - 1; i++) {
I.REP(j => Adj[j].Count.REP(k => {
var cur = Adj[j][k];
if (cost[cur.Item1] > cost[j] + cur.Item2)
cost[cur.Item1] = cost[j] + cur.Item2;
}));
}
for (int i = 0; i < I; i++) {
I.REP(j => Adj[j].Count.REP(k => {
var cur = Adj[j][k];
if (cost[cur.Item1] > cost[j] + cur.Item2) {
cost[cur.Item1] = cost[j] + cur.Item2;
neg[cur.Item1] = true;
}
if (neg[j]) neg[cur.Item1] = true;
}));
}
return cost[t];
}
public bool loopExist() { return neg[I - 1]; }
}
class WarshallFloyd {//そのうちAdjとどっちがいいか...TODO:ジェネリック
private int E; private int INF = (int)1e9; public long[,] G;
public void Init(int n) { E = n + 1; G = new long[E, E]; G.Set(INF); E.REP(i => G[i, i] = 0); }
public void AddPath(int f, int t, long c) { G[f, t] = c; G[t, f] = c; }
public void AddPath(int[] f, int[] t) { f.Length.REP(i => AddPath(f[i], t[i], 1)); }
public void AddPath(int[] f, int[] t, long[] c) { f.Length.REP(i => AddPath(f[i], t[i], c[i])); }
public void Run() { G = MinCostArr(); }
public long[,] MinCostArr() { E.REP(i => E.REP(j => E.REP(k => G[j, k] = Math.Min(G[j, k], G[j, i] + G[i, k])))); return G; }
}
class UnionFind {
public long[] parent; public long[] depth; private int I;
public void Init(int n) { I = n + 1; parent = new long[I]; depth = new long[I]; I.REP(i => parent[i] = i); }
public long Find(long x) { return (parent[x] == x) ? x : parent[x] = Find(parent[x]); }
public void Unite(long x, long y) {
x = Find(x); y = Find(y); if (x == y) return;
if (depth[x] < depth[y]) parent[x] = y; else { parent[y] = x; if (depth[x] == depth[y]) depth[x]++; }
}
public bool Same(int a, int b) { return Find(a) == Find(b); }
public long Size(int x) { return depth[Find(x)]; }
}
class Kruskal : ShortestPath {//TODO:test,
public long Run() {
var L = Adj.Select((l, i) => Tuple.Create(i, l[i].Item1, l[i].Item2)).OrderBy(t => t.Item3).ToList();
//var li = new List<Tuple<int, int, long>>();
//I.REP(i =>{ foreach (var t in Adj[i]) li.Add(Tuple.Create(i, t.Item1, t.Item2));});
//li = li.OrderBy(t => t.Item3).ToList();//li = li.OrderByDescending(t => t.Item3).ToList();
var uf = new UnionFind(); uf.Init(V); long ret = 0;
foreach (var t in L) {
if (!uf.Same(t.Item1, t.Item2)) {
ret += t.Item3; uf.Unite(t.Item1, t.Item2);
}
}
return ret;
}
}
#endregion
#region Ex
static class StringEX {
public static string Reversed(this string s) { return string.Join("", s.Reverse()); }
public static string Repeat(this string s, int n) { return string.Concat(Enumerable.Repeat(s, n).ToArray()); }
public static int toInt(this string s) { int n; return (int.TryParse(s.TrimStart('0'), out n)) ? n : 0; }
public static int toInt(this char c) { return toInt(c.ToString()); }
public static int toInt(this char[] c) { return toInt(new string(c)); }
public static long toLong(this string s) { long n; return (long.TryParse(s.TrimStart('0'), out n)) ? n : (long)0; }
public static long toLong(this char c) { return toLong(c.ToString()); }
public static long toLong(this char[] c) { return toLong(new string(c)); }
public static string toString(this char[] c) { return new string(c); }
}
static class NumericEx {
public static string pad0<T>(this T v, int n) { return v.ToString().PadLeft(n, '0'); }
public static double RoundOff(this double v, int n) { return Math.Round(v, n - 1, MidpointRounding.AwayFromZero); }
public static bool Odd(this int v) { return v % 2 != 0; }
public static bool Odd(this long v) { return v % 2 != 0; }
public static void REP(this int v, Action<int> act) { for (int i = 0; i < v; ++i) act(i); }
public static void REPR(this int v, Action<int> act) { for (int i = v - 1; i >= 0; --i) act(i); }
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) { Array.Sort(a); return a; }
public static T[] SortR<T>(this T[] a) { Array.Sort(a); Array.Reverse(a); return a; }
public static void Set<T>(this T[] a, T v) { a.Length.REP(i => a[i] = v); }
public static void Set<T>(this T[,] a, T v) { a.GetLength(0).REP(i => a.GetLength(1).REP(j => a[i, j] = v)); }
}
static class BitEx {
public static bool Any(this BitArray b) { foreach (bool f in b) if (f) return true; return false; }
public static bool All(this BitArray b) { foreach (bool f in b) if (!f) return false; return true; }
public static bool None(this BitArray b) { return !Any(b); }
public static void Flip(this BitArray b, int index) { b.Set(index, !b.Get(index)); }
}
static class IEnumerableEx {
//
}
#endregion
} | a.cc:47:10: error: invalid preprocessing directive #region
47 | #region MockMacro
| ^~~~~~
a.cc:51:10: error: invalid preprocessing directive #endregion
51 | #endregion
| ^~~~~~~~~
a.cc:54:6: error: invalid preprocessing directive #region
54 | #region default
| ^~~~~~
a.cc:148:6: error: invalid preprocessing directive #endregion
148 | #endregion
| ^~~~~~~~~
a.cc:149:6: error: invalid preprocessing directive #region
149 | #region other
| ^~~~~~
a.cc:261:6: error: invalid preprocessing directive #endregion
261 | #endregion
| ^~~~~~~~~
a.cc:262:6: error: invalid preprocessing directive #region
262 | #region Data
| ^~~~~~
a.cc:420:6: error: invalid preprocessing directive #endregion
420 | #endregion
| ^~~~~~~~~
a.cc:421:6: error: invalid preprocessing directive #region
421 | #region Ex
| ^~~~~~
a.cc:456:6: error: invalid preprocessing directive #endregion
456 | #endregion
| ^~~~~~~~~
a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Collections.Generic;
| ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
4 | using System.Diagnostics;
| ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
5 | using System.IO;
| ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'System'
6 | using System.Linq;
| ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'System'
7 | using System.Linq.Expressions;
| ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'System'
8 | using System.Text;
| ^~~~~~
a.cc:13:13: error: expected unqualified-id before '[' token
13 | long[] v;
| ^
a.cc:42:15: error: expected ':' before 'static'
42 | public static void Main() { new MainClass().Stream(); }
| ^~~~~~~
| :
a.cc:43:9: error: 'IO' does not name a type
43 | IO io = new IO();
| ^~
a.cc:49:32: error: 'Action' has not been declared
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^~~~~~
a.cc:49:38: error: expected ',' or '...' before '<' token
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^
a.cc:50:33: error: 'Action' has not been declared
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^~~~~~
a.cc:50:39: error: expected ',' or '...' before '<' token
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^
a.cc:53:6: error: expected ';' after class definition
53 | }
| ^
| ;
a.cc: In member function 'void Program::MainClass::Solve()':
a.cc:15:13: error: 'io' was not declared in this scope
15 | io.i(out N, out A, out B);
| ^~
a.cc:15:18: error: 'out' was not declared in this scope
15 | io.i(out N, out A, out B);
| ^~~
a.cc:15:29: error: expected ')' before 'A'
15 | io.i(out N, out A, out B);
| ^
a.cc:15:17: note: to match this '('
15 | io.i(out N, out A, out B);
| ^
a.cc:15:36: error: expected ')' before 'B'
15 | io.i(out N, out A, out B);
| ^
a.cc:15:17: note: to match this '('
15 | io.i(out N, out A, out B);
| ^
a.cc:16:24: error: expected ')' before 'v'
16 | io.ini(out v, N);
| ^
a.cc:16:19: note: to match this '('
16 | io.ini(out v, N);
| ^
a.cc:17:13: error: 'Mat' was not declared in this scope
17 | Mat mat = new Mat();
| ^~~
a.cc:18:13: error: 'var' was not declared in this scope
18 | var C = mat.C(50);
| ^~~
a.cc:19:13: error: 'v' was not declared in this scope
19 | v.SortR();
| ^
a.cc:21:15: error: request for member 'REP' in '((Program::MainClass*)this)->Program::MainClass::A', which is of non-class type 'int'
21 | A.REP(i => maxAve += v[i]);
| ^~~
a.cc:21:19: error: 'i' was not declared in this scope
21 | A.REP(i => maxAve += v[i]);
| ^
a.cc:21:22: error: expected primary-expression before '>' token
21 | A.REP(i => maxAve += v[i]);
| ^
a.cc:24:17: error: expected ';' before 'top'
24 | var top = v.First();
| ^~~
a.cc:25:17: error: expected ';' before 'bot'
25 | var bot = v[A - 1];
| ^~~
a.cc:26:17: error: 'top' was not declared in this scope
26 | if (top != bot) {
| ^~~
a.cc:26:24: error: 'bot' was not declared in this scope
26 | if (top != bot) {
| ^~~
a.cc:27:21: error: expected ';' before 'indexedV'
27 | var indexedV = v.Select((e, i) => new { e, i });
| ^~~~~~~~
a.cc:27:63: error: expected primary-expression before ')' token
27 | var indexedV = v.Select((e, i) => new { e, i });
| ^
a.cc:28:21: error: expected ';' before 'choice'
28 | var choice = indexedV.Where(v => v.e == bot).Count();
| ^~~~~~
a.cc:29:21: error: expected ';' before 'choiced'
29 | var choiced = indexedV.Where(v => v.e == bot && v.i < A).Count();
| ^~~~~~~
a.cc:30:23: error: 'C' was not declared in this scope
30 | ans = C[choice, choiced];
| ^
a.cc:30:25: error: 'choice' was not declared in this scope
30 | ans = C[choice, choiced];
| ^~~~~~
a.cc:30:33: error: 'choiced' was not declared in this scope
30 | ans = C[choice, choiced];
| ^~~~~~~
a.cc:32:21: error: expected ';' before 'choice'
32 | var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
| ^~~~~~
a.cc:32:61: error: expected primary-expression before ')' token
32 | var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
| ^
a.cc:34:25: error: 'choice' was not declared in this scope
34 | if (choice < i) break;
| ^~~~~~
a.cc:35:28: error: 'C' was not declared in this scope
35 | ans += C[choice, i];
| ^
a.cc:35:30: error: 'choice' was not declared in this scope
35 | ans += C[choice, i];
| ^~~~~~
a.cc: In static member function 'static void Program::MainClass::Main()':
a.cc:42:52: error: expected ';' before '.' token
42 | public static void Main() { new MainClass().Stream(); }
| ^
a.cc: In member function 'void Program::MainClass::Stream()':
a.cc:44:34: error: 'io' was not declared in this scope
44 | void Stream() { Solve(); io.writeFlush(); }
| ^~
a.cc: In member function 'void Program::MainClass::FOR(int, int, int)':
a.cc:49:79: error: 'act' was not declared in this scope
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^~~
a.cc: In member function 'void Program::MainClass::FORR(int, int, int)':
a.cc:50:85: error: 'act' was not declared in this scope
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^~~
a.cc: At global scope:
a.cc:56:9: error: 'TYPE' does not name a type
56 | TYPE tp;
| ^~~~
a.cc:57:9: error: 'string' does not name a type
57 | string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
| ^~~~~~
a.cc:57:49: error: expected unqualified-id before '[' token
57 | string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
| ^
a.cc:58:9: error: 'StreamWriter' does not name a type
58 | StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
| ^~~~~~~~~~~~
a.cc:59:15: error: expected ':' before 'IO'
59 | public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); tp = new TYPE(); }
| ^~~
| :
a.cc:60:15: error: expected ':' before 'string'
60 | public string Next() {
| ^~~~~~~
| :
a.cc:60:16: error: 'string' does not name a type
60 | public string Next() {
| ^~~~~~
a.cc:68:15: error: expected ':' before 'string'
68 | public string String => Next();
| ^~~~~~~
| :
a.cc:68:16: error: 'string' does not name a type
68 | public string String => Next();
| ^~~~~~
a.cc:69:15: error: expected ':' before 'char'
69 | public char Char => char.Parse(String);
|
s379624574 | p03776 | C++ | using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Program {
class MainClass {
////////////////////////////////////////////////////////////
int N, A, B;
long[] v;
void Solve() {
io.i(out N, out A, out B);
io.ini(out v, N);
Mat mat = new Mat();
var C = mat.C(50);
v.SortR();
double maxAve = 0;
A.REP(i => maxAve += v[i]);
maxAve /= A;
long ans = 0;
var top = v.First();
var bot = v[A - 1];
if (top != bot) {
var indexedV = v.Select((e, i) => new { e, i });
var choice = indexedV.Where(v => v.e == bot).Count();
var choiced = indexedV.Where(v => v.e == bot && v.i < A).Count();
ans = C[choice, choiced];
} else {
var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
for (int i = A; i <= B; i++) {
if (choice < i) break;
ans += C[choice, i];
}
}
io.o(maxAve);
io.o(ans);
}
////////////////////////////////////////////////////////////
public static void Main() { new MainClass().Stream(); }
IO io = new IO();
void Stream() { Solve(); io.writeFlush(); }
//void Stream() { Test(); io.writeFlush(); }
void Test() { }
#region MockMacro
//cannot use break,continue,goto
void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
#endregion
////////////////////////////////////////////////////////////
}
#region default
class IO {
TYPE tp;
string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); tp = new TYPE(); }
public string Next() {
if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "") st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public string String => Next();
public char Char => char.Parse(String);
public int Int => int.Parse(String);
public long Long => long.Parse(String);
public double Double => double.Parse(String);
public string[] arr => Console.ReadLine().Split(' ');
public char[] arrChar => Array.ConvertAll(arr, char.Parse);
public int[] arrInt => Array.ConvertAll(arr, int.Parse);
public long[] arrLong => Array.ConvertAll(arr, long.Parse);
public double[] arrDouble => Array.ConvertAll(arr, double.Parse);
public T i<T>() { return tp.suitType<T>(String); }
public void i<T>(out T v) { v = tp.suitType<T>(String); }
public void i<T, U>(out T v1, out U v2) { i(out v1); i(out v2); }
public void i<T, U, V>(out T v1, out U v2, out V v3) { i(out v1); i(out v2); i(out v3); }
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
i(out v1); i(out v2); i(out v3); i(out v4);
}
public void i<T, U, V, W, X>(out T v1, out U v2, out V v3, out W v4, out X v5) {
i(out v1); i(out v2); i(out v3); i(out v4); i(out v5);
}
public void ini<T>(out T[] a, int n) { a = new T[n]; for (int i = 0; i < n; i++) a[i] = tp.suitType<T>(String); }
public void ini<T, U>(out T[] a, out U[] b, int n) {
a = new T[n]; b = new U[n]; for (int i = 0; i < n; i++) { a[i] = i<T>(); b[i] = i<U>(); }
}
public void ini<T, U, V>(out T[] a, out U[] b, out V[] c, int n) {
a = new T[n]; b = new U[n]; c = new V[n];
for (int i = 0; i < n; i++) { a[i] = i<T>(); b[i] = i<U>(); c[i] = i<V>(); }
}
public void ini<T>(out T[,] a, int h, int w) {
a = new T[h, w]; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) a[i, j] = i<T>();
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) { Array.ForEach(a, n => o(n)); }
public void o<T>(T[,] a) { a.GetLength(0).REP(i => { a.GetLength(1).REP(j => or(a[i, j] + " ")); br(); }); }
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) { o(connect<T>(a)); }
public void or<T>(T a) { Console.Write(a); }
public void br() { o(""); }
public void writeFlush() { Console.Out.Flush(); }
private string connect<T>(params T[] s) { return string.Join(" ", s); }
}
class TYPE {
public bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
public T convertType<T, U>(U v) { return (T)Convert.ChangeType(v, typeof(T)); }
public T suitType<T>(string s) {
if (typeEQ<T, int>()) return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>()) return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>()) return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>()) return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
}
class PQueue<T> where T : IComparable {
public List<T> heap; private Comparison<T> comp; private IComparer<T> comparer;
private int size; private int type;//type=0->min
public PQueue(int type = 0) : this(Comparer<T>.Default) { this.type = type; }
public PQueue(IComparer<T> comparer) : this(16, comparer.Compare) { this.comparer = comparer; }
public PQueue(Comparison<T> comparison) : this(16, comparison) { }
public PQueue(int capacity, Comparison<T> comparison) { this.heap = new List<T>(capacity); this.comp = comparison; }
public void Enqueue(T item) {
this.heap.Add(item); var i = size++;
while (i > 0) { var p = (i - 1) >> 1; if (Compare(this.heap[p], item) <= 0) break; this.heap[i] = heap[p]; i = p; }
this.heap[i] = item;
}
public T Dequeue() {
var ret = this.heap[0]; var x = this.heap[--size]; var i = 0;
while ((i << 1) + 1 < size) {
var a = (i << 1) + 1; var b = (i << 1) + 2; if (b < size && Compare(heap[b], heap[a]) < 0) a = b;
if (Compare(heap[a], x) >= 0) break; heap[i] = heap[a]; i = a;
}
heap[i] = x; heap.RemoveAt(size);
return ret;
}
public T Peek() { return heap[0]; }
public int Count { get { return size; } }
public bool Any() { return size > 0; }
public bool Empty() { return !Any(); }
public bool Contains(T v) { return heap.Contains(v); }
private int Compare(T x, T y) { return type == 0 ? x.CompareTo(y) : y.CompareTo(x); }
}
#endregion
#region other
class Mat {
public long mod = 1000000007;//10^9+7
public long Pow(long a, long b) {
if (b == 0) return 1;
if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) { long ret = 1; for (long i = 1; i <= n; i++) ret = (ret * i) % mod; return ret; }
public long ModC(long n, long r) {
if (r == 0 || n == r) return 1;
if (n == 0) return 0;
if (n < 0 || n < r) throw new ArgumentException("n,r invalid");
else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
}
public long[,] C(int N) {
long[,] Co = new long[N + 1, N + 1];
(N + 1).REP(i => (i + 1).REP(j => Co[i, j] = (j == 0 || j == i) ? 1L : Co[i - 1, j - 1] + Co[i - 1, j]));
return Co;
}
public long DupC(long n, long r) { return ModC(n + r - 1, r); }
public long P(long n, long r) { return Fact(n) / (Fact(n - r)); }//test
public bool isPrime(long n) {
if (n == 2) return true; if (n < 2 || n % 2 == 0) return false;
for (long v = 3; v <= (long)Math.Sqrt(n); v += 2) if (n % v == 0) return false;
return true;
}
public long LCM(long a, long b) { return a * (b / GCD(a, b)); }
public long LCM(params long[] a) { return a.Aggregate((v, n) => LCM(v, n)); }
public long GCD(long a, long b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
public long GCD(params long[] array) { return array.Aggregate((v, n) => GCD(v, n)); }
public T Max<T>(params T[] a) { return a.Max(); }
public T Min<T>(params T[] a) { return a.Min(); }
public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
public double Dis(int x1, int y1, int x2, int y2) { return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)); }
public int mDis(int x1, int y1, int x2, int y2) { return Math.Abs(x1 - x2) + Math.Abs(y1 - y2); }
public int[] DigArr(int n) { int[] ret = new int[Digit(n)]; ret.Length.REP(i => ret[i] = DigVal(n, i + 1)); return ret; }
public long DigArr2Num(IEnumerable<int> enu) { return enu.Aggregate((v, n) => v * 10 + n); }
public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; }
public int DigVal(int n, int dig) { return (n % (int)Pow(10, dig)) / (int)Pow(10, dig - 1); }
public long Tousa(long a, long d, long n) { return a + (n - 1) * d; }
public long TousaSum(long a, long d, long n) { return n * (2 * a + (n - 1) * d) / 2; }
public long[] enuDivsor(long N) {
var ret = new SortedSet<long>();
for (long i = 1; i * i <= N; i++)
if (N % i == 0) { ret.Add(i); ret.Add(N / i); }
return ret.ToArray();
}
public IEnumerable<int[]> enuP(int[] Arr, int Use = -1) {//列挙順列
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0 || Arr.Length < Use) yield break;
var s = new Stack<List<int>>();
Arr.Length.REPR(i => s.Push(new List<int>() { i }));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Count == Use) {
var ret = new List<int>(); cur.ForEach(X => ret.Add(Arr[X]));
yield return ret.ToArray();
} else
Arr.Length.REPR(i => { if (!cur.Contains(i)) s.Push(new List<int>(cur) { i }); });
}
}
public IEnumerable<int[]> enuC(int[] Arr, int Use = -1) {//列挙組み合わせ
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0 || Arr.Length < Use) yield break;
var s = new Stack<Tuple<int, List<int>>>();
Arr.Length.REPR(i => s.Push(Tuple.Create(i, new List<int>() { Arr[i] })));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item2.Count == Use) yield return cur.Item2.ToArray();
else for (int i = Arr.GetUpperBound(0); i > cur.Item1; i--)
s.Push(Tuple.Create(i, new List<int>(cur.Item2) { Arr[i] }));
}
}
public IEnumerable<int[]> enuDupP(int[] Arr, int Use = -1) {//列挙重複順列
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0) yield break; var s = new Stack<List<int>>();
Arr.Length.REPR(i => s.Push(new List<int>() { Arr[i] }));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Count == Use) yield return cur.ToArray();
else Arr.Length.REPR(i => s.Push(new List<int>(cur) { Arr[i] }));
}
}
public IEnumerable<int[]> enuDupC(int[] Arr, int Use = -1) {//列挙組み合わせ
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0) yield break;
var s = new Stack<Tuple<int, List<int>>>();
Arr.Length.REPR(i => s.Push(Tuple.Create(i, new List<int>() { Arr[i] })));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item2.Count == Use) yield return cur.Item2.ToArray();
else for (int i = Arr.GetUpperBound(0); i >= cur.Item1; i--)
s.Push(Tuple.Create(i, new List<int>(cur.Item2) { Arr[i] }));
}
}
public IEnumerable<long[]> enuPart(string str) {
var s = new Stack<Tuple<string, List<long>, int>>();
s.Push(Tuple.Create(str[0].ToString(), new List<long>(), 1));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item3 >= str.Length) yield return (new List<long>(cur.Item2) { cur.Item1.toLong() }).ToArray();
else {
s.Push(Tuple.Create(cur.Item1 + str[cur.Item3], new List<long>(cur.Item2), cur.Item3 + 1));
s.Push(Tuple.Create(str[cur.Item3].ToString(), new List<long>(cur.Item2) { cur.Item1.toLong() }, cur.Item3 + 1));
}
}
}
}
class Time {
public int[] M = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
public int[] D = { 31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
public Time() { D[1] = 28; }
public Time(int y) { D[1] = isLeapYear(y) ? 29 : 28; }
public bool isLeapYear(int y) { return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)); }
}
#endregion
#region Data
class AssociativeArray<T> : IEnumerable {
public Dictionary<T, int> dic;
public AssociativeArray() { dic = new Dictionary<T, int>(); }
public AssociativeArray(params T[] a) { dic = new Dictionary<T, int>(); Add(a); }
public void Add(T a) { if (!conK(a)) dic[a] = 0; dic[a]++; }
public void Add(params T[] a) { a.Length.REP(i => { if (!conK(a[i])) dic[a[i]] = 0; dic[a[i]]++; }); }
public void Set(T k, int v) { if (!dic.ContainsKey(k)) dic[k] = 0; dic[k] = v; }
public void Remove(params T[] a) { a.Length.REP(i => { if (conK(a[i])) dic.Remove(a[i]); }); }
public T[] Keys() { return dic.Keys.ToArray<T>(); }
public int Val(T k) { return (dic.ContainsKey(k)) ? dic[k] : 0; }
public int ValSum => dic.Values.Sum();
public int KeyNum => dic.Keys.Count;
public int MaxVal => dic.Values.Max();
public int MinVal => dic.Values.Min();
public T MaxKey => MaxK();
public T MinKey => MinK();
public T MaxK() { var maxV = MaxVal; return dic.First(d => d.Value == maxV).Key; }
public T MinK() { var minV = MinVal; return dic.First(d => d.Value == minV).Key; }
public bool conK(T k) { return dic.ContainsKey(k); }
public bool anyK(params T[] k) { return k.Any(key => conK(key)); }
public bool allK(params T[] k) { return k.All(key => conK(key)); }
public void Show() { foreach (var v in dic) { Console.WriteLine(v.Key + " : " + v.Value); } }
public IEnumerator GetEnumerator() { foreach (var kp in dic) yield return kp; }
public T[] ValueSortedKey(bool inc = true) {//test
return (inc ? (dic.OrderBy(kp => kp.Value)) : (dic.OrderByDescending(kp => kp.Value)))
.ThenBy(kp => kp.Key).ToDictionary(kp => kp.Key, kp => kp.Value).Keys.ToArray();
}
//:sort->array
}
class Index {
public int[] Comp(int[] bef) {
int[] aft = new int[bef.Length];
var tmp = bef.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);
aft = bef.Select(v => tmp[v]).ToArray();
return aft;
}
}
class TreeDis {//TODO:shortestPath
public List<Tuple<long, long>>[] g; public long[] a2other; private int type;
public TreeDis(int type = 0) { this.type = type; }//0->bfs,other->dfs
public void Init(long n) { g = new List<Tuple<long, long>>[n + 1]; g.Length.REP(i => g[i] = new List<Tuple<long, long>>()); }
public void Run(long[] a, long[] b) { a.Length.REP(i => { g[a[i]].Add(Tuple.Create(b[i], 1L)); g[b[i]].Add(Tuple.Create(a[i], 1L)); }); }
public void Run(long[] a, long[] b, long[] w) { a.Length.REP(i => { g[a[i]].Add(Tuple.Create(b[i], w[i])); g[b[i]].Add(Tuple.Create(a[i], w[i])); }); }
public long[] a2iArr(long a) { a2other = new long[g.Count()]; if (type == 0) BFS(a); else DFS(a); return a2other; }
private void BFS(long a) {
var q = new Queue<Tuple<long, long>>(); q.Enqueue(Tuple.Create(a, -1L));
while (q.Count > 0) {
var c = q.Dequeue();
foreach (var v in g[c.Item1]) {
if (v.Item1 == c.Item2) continue;
a2other[v.Item1] = a2other[c.Item1] + v.Item2; q.Enqueue(Tuple.Create(v.Item1, c.Item1));
}
}
}
private void DFS(long a) {
var s = new Stack<Tuple<long, long>>(); s.Push(Tuple.Create(a, -1L));
while (s.Count > 0) {
var c = s.Pop();
foreach (var v in g[c.Item1]) {
if (v.Item1 == c.Item2) continue;
a2other[v.Item1] = a2other[c.Item1] + v.Item2; s.Push(Tuple.Create(v.Item1, c.Item1));
}
}
}
}
class ShortestPath {
public long INF = (long)1e15; protected int I = -1; protected int V; protected int E; public long[] cost;
public List<Tuple<int, long>>[] Adj; protected bool isNonDir = true;
public void Init(int n) { I = n + 1; V = n; Adj = new List<Tuple<int, long>>[I]; I.REP(i => Adj[i] = new List<Tuple<int, long>>()); }
public void AddPath(int f, int t, long c) {
E++;
if (isNonDir) {
Adj[f].Add(Tuple.Create(t, c)); Adj[t].Add(Tuple.Create(f, c));
} else {
Adj[f].Add(Tuple.Create(t, c));
}
}
public void AddPath(int[] f, int[] t, long[] c) { f.Length.REP(i => AddPath(f[i], t[i], c[i])); }
}
class Dijkstra : ShortestPath {//隣接対応後検証不足,有向とか
public long MinCost(int f, int t) {
cost = new long[I]; cost.Set(INF); cost[f] = 0;
var pq = new PQueue<Tuple<int, long>>(); pq.Enqueue(Tuple.Create(f, 0L));//(from,cost)
while (pq.Count > 0) {
var cur = pq.Dequeue();
if (cost[cur.Item1] < cur.Item2) continue; Adj[cur.Item1].Count.REP(i => {
var tmp = Adj[cur.Item1][i];
if (cost[tmp.Item1] > cost[cur.Item1] + tmp.Item2) {
cost[tmp.Item1] = cost[cur.Item1] + tmp.Item2; pq.Enqueue(Tuple.Create(tmp.Item1, cost[tmp.Item1]));
}
});
}
return cost[t];
}
}
class BellmanFord : ShortestPath {
private bool[] neg;
public BellmanFord() { }
public BellmanFord(bool isNonDir) { this.isNonDir = isNonDir; }
public long MinCost(int f, int t) {
cost = new long[I]; cost.Set(INF); cost[f] = 0; neg = new bool[I];
for (int i = 0; i < I - 1; i++) {
I.REP(j => Adj[j].Count.REP(k => {
var cur = Adj[j][k];
if (cost[cur.Item1] > cost[j] + cur.Item2)
cost[cur.Item1] = cost[j] + cur.Item2;
}));
}
for (int i = 0; i < I; i++) {
I.REP(j => Adj[j].Count.REP(k => {
var cur = Adj[j][k];
if (cost[cur.Item1] > cost[j] + cur.Item2) {
cost[cur.Item1] = cost[j] + cur.Item2;
neg[cur.Item1] = true;
}
if (neg[j]) neg[cur.Item1] = true;
}));
}
return cost[t];
}
public bool loopExist() { return neg[I - 1]; }
}
class WarshallFloyd {//そのうちAdjとどっちがいいか...TODO:ジェネリック
private int E; private int INF = (int)1e9; public long[,] G;
public void Init(int n) { E = n + 1; G = new long[E, E]; G.Set(INF); E.REP(i => G[i, i] = 0); }
public void AddPath(int f, int t, long c) { G[f, t] = c; G[t, f] = c; }
public void AddPath(int[] f, int[] t) { f.Length.REP(i => AddPath(f[i], t[i], 1)); }
public void AddPath(int[] f, int[] t, long[] c) { f.Length.REP(i => AddPath(f[i], t[i], c[i])); }
public void Run() { G = MinCostArr(); }
public long[,] MinCostArr() { E.REP(i => E.REP(j => E.REP(k => G[j, k] = Math.Min(G[j, k], G[j, i] + G[i, k])))); return G; }
}
class UnionFind {
public long[] parent; public long[] depth; private int I;
public void Init(int n) { I = n + 1; parent = new long[I]; depth = new long[I]; I.REP(i => parent[i] = i); }
public long Find(long x) { return (parent[x] == x) ? x : parent[x] = Find(parent[x]); }
public void Unite(long x, long y) {
x = Find(x); y = Find(y); if (x == y) return;
if (depth[x] < depth[y]) parent[x] = y; else { parent[y] = x; if (depth[x] == depth[y]) depth[x]++; }
}
public bool Same(int a, int b) { return Find(a) == Find(b); }
public long Size(int x) { return depth[Find(x)]; }
}
class Kruskal : ShortestPath {//TODO:test,
public long Run() {
var L = Adj.Select((l, i) => Tuple.Create(i, l[i].Item1, l[i].Item2)).OrderBy(t => t.Item3).ToList();
//var li = new List<Tuple<int, int, long>>();
//I.REP(i =>{ foreach (var t in Adj[i]) li.Add(Tuple.Create(i, t.Item1, t.Item2));});
//li = li.OrderBy(t => t.Item3).ToList();//li = li.OrderByDescending(t => t.Item3).ToList();
var uf = new UnionFind(); uf.Init(V); long ret = 0;
foreach (var t in L) {
if (!uf.Same(t.Item1, t.Item2)) {
ret += t.Item3; uf.Unite(t.Item1, t.Item2);
}
}
return ret;
}
}
#endregion
#region Ex
static class StringEX {
public static string Reversed(this string s) { return string.Join("", s.Reverse()); }
public static string Repeat(this string s, int n) { return string.Concat(Enumerable.Repeat(s, n).ToArray()); }
public static int toInt(this string s) { int n; return (int.TryParse(s.TrimStart('0'), out n)) ? n : 0; }
public static int toInt(this char c) { return toInt(c.ToString()); }
public static int toInt(this char[] c) { return toInt(new string(c)); }
public static long toLong(this string s) { long n; return (long.TryParse(s.TrimStart('0'), out n)) ? n : (long)0; }
public static long toLong(this char c) { return toLong(c.ToString()); }
public static long toLong(this char[] c) { return toLong(new string(c)); }
public static string toString(this char[] c) { return new string(c); }
}
static class NumericEx {
public static string pad0<T>(this T v, int n) { return v.ToString().PadLeft(n, '0'); }
public static double RoundOff(this double v, int n) { return Math.Round(v, n - 1, MidpointRounding.AwayFromZero); }
public static bool Odd(this int v) { return v % 2 != 0; }
public static bool Odd(this long v) { return v % 2 != 0; }
public static void REP(this int v, Action<int> act) { for (int i = 0; i < v; ++i) act(i); }
public static void REPR(this int v, Action<int> act) { for (int i = v - 1; i >= 0; --i) act(i); }
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) { Array.Sort(a); return a; }
public static T[] SortR<T>(this T[] a) { Array.Sort(a); Array.Reverse(a); return a; }
public static void Set<T>(this T[] a, T v) { a.Length.REP(i => a[i] = v); }
public static void Set<T>(this T[,] a, T v) { a.GetLength(0).REP(i => a.GetLength(1).REP(j => a[i, j] = v)); }
}
static class BitEx {
public static bool Any(this BitArray b) { foreach (bool f in b) if (f) return true; return false; }
public static bool All(this BitArray b) { foreach (bool f in b) if (!f) return false; return true; }
public static bool None(this BitArray b) { return !Any(b); }
public static void Flip(this BitArray b, int index) { b.Set(index, !b.Get(index)); }
}
static class IEnumerableEx {
//
}
#endregion
} | a.cc:47:10: error: invalid preprocessing directive #region
47 | #region MockMacro
| ^~~~~~
a.cc:51:10: error: invalid preprocessing directive #endregion
51 | #endregion
| ^~~~~~~~~
a.cc:54:6: error: invalid preprocessing directive #region
54 | #region default
| ^~~~~~
a.cc:148:6: error: invalid preprocessing directive #endregion
148 | #endregion
| ^~~~~~~~~
a.cc:149:6: error: invalid preprocessing directive #region
149 | #region other
| ^~~~~~
a.cc:261:6: error: invalid preprocessing directive #endregion
261 | #endregion
| ^~~~~~~~~
a.cc:262:6: error: invalid preprocessing directive #region
262 | #region Data
| ^~~~~~
a.cc:420:6: error: invalid preprocessing directive #endregion
420 | #endregion
| ^~~~~~~~~
a.cc:421:6: error: invalid preprocessing directive #region
421 | #region Ex
| ^~~~~~
a.cc:456:6: error: invalid preprocessing directive #endregion
456 | #endregion
| ^~~~~~~~~
a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Collections.Generic;
| ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
4 | using System.Diagnostics;
| ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
5 | using System.IO;
| ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'System'
6 | using System.Linq;
| ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'System'
7 | using System.Linq.Expressions;
| ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'System'
8 | using System.Text;
| ^~~~~~
a.cc:13:13: error: expected unqualified-id before '[' token
13 | long[] v;
| ^
a.cc:42:15: error: expected ':' before 'static'
42 | public static void Main() { new MainClass().Stream(); }
| ^~~~~~~
| :
a.cc:43:9: error: 'IO' does not name a type
43 | IO io = new IO();
| ^~
a.cc:49:32: error: 'Action' has not been declared
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^~~~~~
a.cc:49:38: error: expected ',' or '...' before '<' token
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^
a.cc:50:33: error: 'Action' has not been declared
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^~~~~~
a.cc:50:39: error: expected ',' or '...' before '<' token
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^
a.cc:53:6: error: expected ';' after class definition
53 | }
| ^
| ;
a.cc: In member function 'void Program::MainClass::Solve()':
a.cc:15:13: error: 'io' was not declared in this scope
15 | io.i(out N, out A, out B);
| ^~
a.cc:15:18: error: 'out' was not declared in this scope
15 | io.i(out N, out A, out B);
| ^~~
a.cc:15:29: error: expected ')' before 'A'
15 | io.i(out N, out A, out B);
| ^
a.cc:15:17: note: to match this '('
15 | io.i(out N, out A, out B);
| ^
a.cc:15:36: error: expected ')' before 'B'
15 | io.i(out N, out A, out B);
| ^
a.cc:15:17: note: to match this '('
15 | io.i(out N, out A, out B);
| ^
a.cc:16:24: error: expected ')' before 'v'
16 | io.ini(out v, N);
| ^
a.cc:16:19: note: to match this '('
16 | io.ini(out v, N);
| ^
a.cc:17:13: error: 'Mat' was not declared in this scope
17 | Mat mat = new Mat();
| ^~~
a.cc:18:13: error: 'var' was not declared in this scope
18 | var C = mat.C(50);
| ^~~
a.cc:19:13: error: 'v' was not declared in this scope
19 | v.SortR();
| ^
a.cc:21:15: error: request for member 'REP' in '((Program::MainClass*)this)->Program::MainClass::A', which is of non-class type 'int'
21 | A.REP(i => maxAve += v[i]);
| ^~~
a.cc:21:19: error: 'i' was not declared in this scope
21 | A.REP(i => maxAve += v[i]);
| ^
a.cc:21:22: error: expected primary-expression before '>' token
21 | A.REP(i => maxAve += v[i]);
| ^
a.cc:24:17: error: expected ';' before 'top'
24 | var top = v.First();
| ^~~
a.cc:25:17: error: expected ';' before 'bot'
25 | var bot = v[A - 1];
| ^~~
a.cc:26:17: error: 'top' was not declared in this scope
26 | if (top != bot) {
| ^~~
a.cc:26:24: error: 'bot' was not declared in this scope
26 | if (top != bot) {
| ^~~
a.cc:27:21: error: expected ';' before 'indexedV'
27 | var indexedV = v.Select((e, i) => new { e, i });
| ^~~~~~~~
a.cc:27:63: error: expected primary-expression before ')' token
27 | var indexedV = v.Select((e, i) => new { e, i });
| ^
a.cc:28:21: error: expected ';' before 'choice'
28 | var choice = indexedV.Where(v => v.e == bot).Count();
| ^~~~~~
a.cc:29:21: error: expected ';' before 'choiced'
29 | var choiced = indexedV.Where(v => v.e == bot && v.i < A).Count();
| ^~~~~~~
a.cc:30:23: error: 'C' was not declared in this scope
30 | ans = C[choice, choiced];
| ^
a.cc:30:25: error: 'choice' was not declared in this scope
30 | ans = C[choice, choiced];
| ^~~~~~
a.cc:30:33: error: 'choiced' was not declared in this scope
30 | ans = C[choice, choiced];
| ^~~~~~~
a.cc:32:21: error: expected ';' before 'choice'
32 | var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
| ^~~~~~
a.cc:32:61: error: expected primary-expression before ')' token
32 | var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
| ^
a.cc:34:25: error: 'choice' was not declared in this scope
34 | if (choice < i) break;
| ^~~~~~
a.cc:35:28: error: 'C' was not declared in this scope
35 | ans += C[choice, i];
| ^
a.cc:35:30: error: 'choice' was not declared in this scope
35 | ans += C[choice, i];
| ^~~~~~
a.cc: In static member function 'static void Program::MainClass::Main()':
a.cc:42:52: error: expected ';' before '.' token
42 | public static void Main() { new MainClass().Stream(); }
| ^
a.cc: In member function 'void Program::MainClass::Stream()':
a.cc:44:34: error: 'io' was not declared in this scope
44 | void Stream() { Solve(); io.writeFlush(); }
| ^~
a.cc: In member function 'void Program::MainClass::FOR(int, int, int)':
a.cc:49:79: error: 'act' was not declared in this scope
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^~~
a.cc: In member function 'void Program::MainClass::FORR(int, int, int)':
a.cc:50:85: error: 'act' was not declared in this scope
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^~~
a.cc: At global scope:
a.cc:56:9: error: 'TYPE' does not name a type
56 | TYPE tp;
| ^~~~
a.cc:57:9: error: 'string' does not name a type
57 | string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
| ^~~~~~
a.cc:57:49: error: expected unqualified-id before '[' token
57 | string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
| ^
a.cc:58:9: error: 'StreamWriter' does not name a type
58 | StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
| ^~~~~~~~~~~~
a.cc:59:15: error: expected ':' before 'IO'
59 | public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); tp = new TYPE(); }
| ^~~
| :
a.cc:60:15: error: expected ':' before 'string'
60 | public string Next() {
| ^~~~~~~
| :
a.cc:60:16: error: 'string' does not name a type
60 | public string Next() {
| ^~~~~~
a.cc:68:15: error: expected ':' before 'string'
68 | public string String => Next();
| ^~~~~~~
| :
a.cc:68:16: error: 'string' does not name a type
68 | public string String => Next();
| ^~~~~~
a.cc:69:15: error: expected ':' before 'char'
69 | public char Char => char.Parse(String);
|
s884648161 | p03776 | C++ | using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Program {
class MainClass {
////////////////////////////////////////////////////////////
int N, A, B;
long[] v;
void Solve() {
io.i(out N, out A, out B);
io.ini(out v, N);
Mat mat = new Mat();
var C = mat.C(50);
v.SortR();
double maxAve = 0;
A.REP(i => maxAve += v[i]);
maxAve /= A;
long ans = 0;
var top = v.First();
var bot = v[A - 1];
if (top != bot) {
var indexedV = v.Select((e, i) => new { e, i });
var choice = indexedV.Where(v => v.e == bot).Count();
var choiced = indexedV.Where(v => v.e == bot && v.i < A).Count();
ans = C[choice, choiced];
} else {
var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
for (int i = A; i <= B; i++) {
if (choice < i) break;
ans += C[choice, i];
}
}
io.o(maxAve);
io.o(ans);
}
////////////////////////////////////////////////////////////
public static void Main() { new MainClass().Stream(); }
IO io = new IO();
void Stream() { Solve(); io.writeFlush(); }
//void Stream() { Test(); io.writeFlush(); }
void Test() { }
#region MockMacro
//cannot use break,continue,goto
void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
#endregion
////////////////////////////////////////////////////////////
}
#region default
class IO {
TYPE tp;
string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); tp = new TYPE(); }
public string Next() {
if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "") st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public string String => Next();
public char Char => char.Parse(String);
public int Int => int.Parse(String);
public long Long => long.Parse(String);
public double Double => double.Parse(String);
public string[] arr => Console.ReadLine().Split(' ');
public char[] arrChar => Array.ConvertAll(arr, char.Parse);
public int[] arrInt => Array.ConvertAll(arr, int.Parse);
public long[] arrLong => Array.ConvertAll(arr, long.Parse);
public double[] arrDouble => Array.ConvertAll(arr, double.Parse);
public T i<T>() { return tp.suitType<T>(String); }
public void i<T>(out T v) { v = tp.suitType<T>(String); }
public void i<T, U>(out T v1, out U v2) { i(out v1); i(out v2); }
public void i<T, U, V>(out T v1, out U v2, out V v3) { i(out v1); i(out v2); i(out v3); }
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
i(out v1); i(out v2); i(out v3); i(out v4);
}
public void i<T, U, V, W, X>(out T v1, out U v2, out V v3, out W v4, out X v5) {
i(out v1); i(out v2); i(out v3); i(out v4); i(out v5);
}
public void ini<T>(out T[] a, int n) { a = new T[n]; for (int i = 0; i < n; i++) a[i] = tp.suitType<T>(String); }
public void ini<T, U>(out T[] a, out U[] b, int n) {
a = new T[n]; b = new U[n]; for (int i = 0; i < n; i++) { a[i] = i<T>(); b[i] = i<U>(); }
}
public void ini<T, U, V>(out T[] a, out U[] b, out V[] c, int n) {
a = new T[n]; b = new U[n]; c = new V[n];
for (int i = 0; i < n; i++) { a[i] = i<T>(); b[i] = i<U>(); c[i] = i<V>(); }
}
public void ini<T>(out T[,] a, int h, int w) {
a = new T[h, w]; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) a[i, j] = i<T>();
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) { Array.ForEach(a, n => o(n)); }
public void o<T>(T[,] a) { a.GetLength(0).REP(i => { a.GetLength(1).REP(j => or(a[i, j] + " ")); br(); }); }
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) { o(connect<T>(a)); }
public void or<T>(T a) { Console.Write(a); }
public void br() { o(""); }
public void writeFlush() { Console.Out.Flush(); }
private string connect<T>(params T[] s) { return string.Join(" ", s); }
}
class TYPE {
public bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
public T convertType<T, U>(U v) { return (T)Convert.ChangeType(v, typeof(T)); }
public T suitType<T>(string s) {
if (typeEQ<T, int>()) return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>()) return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>()) return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>()) return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
}
class PQueue<T> where T : IComparable {
public List<T> heap; private Comparison<T> comp; private IComparer<T> comparer;
private int size; private int type;//type=0->min
public PQueue(int type = 0) : this(Comparer<T>.Default) { this.type = type; }
public PQueue(IComparer<T> comparer) : this(16, comparer.Compare) { this.comparer = comparer; }
public PQueue(Comparison<T> comparison) : this(16, comparison) { }
public PQueue(int capacity, Comparison<T> comparison) { this.heap = new List<T>(capacity); this.comp = comparison; }
public void Enqueue(T item) {
this.heap.Add(item); var i = size++;
while (i > 0) { var p = (i - 1) >> 1; if (Compare(this.heap[p], item) <= 0) break; this.heap[i] = heap[p]; i = p; }
this.heap[i] = item;
}
public T Dequeue() {
var ret = this.heap[0]; var x = this.heap[--size]; var i = 0;
while ((i << 1) + 1 < size) {
var a = (i << 1) + 1; var b = (i << 1) + 2; if (b < size && Compare(heap[b], heap[a]) < 0) a = b;
if (Compare(heap[a], x) >= 0) break; heap[i] = heap[a]; i = a;
}
heap[i] = x; heap.RemoveAt(size);
return ret;
}
public T Peek() { return heap[0]; }
public int Count { get { return size; } }
public bool Any() { return size > 0; }
public bool Empty() { return !Any(); }
public bool Contains(T v) { return heap.Contains(v); }
private int Compare(T x, T y) { return type == 0 ? x.CompareTo(y) : y.CompareTo(x); }
}
#endregion
#region other
class Mat {
public long mod = 1000000007;//10^9+7
public long Pow(long a, long b) {
if (b == 0) return 1;
if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) { long ret = 1; for (long i = 1; i <= n; i++) ret = (ret * i) % mod; return ret; }
public long ModC(long n, long r) {
if (r == 0 || n == r) return 1;
if (n == 0) return 0;
if (n < 0 || n < r) throw new ArgumentException("n,r invalid");
else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
}
public long[,] C(int N) {
long[,] Co = new long[N + 1, N + 1];
(N + 1).REP(i => (i + 1).REP(j => Co[i, j] = (j == 0 || j == i) ? 1L : Co[i - 1, j - 1] + Co[i - 1, j]));
return Co;
}
public long DupC(long n, long r) { return ModC(n + r - 1, r); }
public long P(long n, long r) { return Fact(n) / (Fact(n - r)); }//test
public bool isPrime(long n) {
if (n == 2) return true; if (n < 2 || n % 2 == 0) return false;
for (long v = 3; v <= (long)Math.Sqrt(n); v += 2) if (n % v == 0) return false;
return true;
}
public long LCM(long a, long b) { return a * (b / GCD(a, b)); }
public long LCM(params long[] a) { return a.Aggregate((v, n) => LCM(v, n)); }
public long GCD(long a, long b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
public long GCD(params long[] array) { return array.Aggregate((v, n) => GCD(v, n)); }
public T Max<T>(params T[] a) { return a.Max(); }
public T Min<T>(params T[] a) { return a.Min(); }
public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
public double Dis(int x1, int y1, int x2, int y2) { return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)); }
public int mDis(int x1, int y1, int x2, int y2) { return Math.Abs(x1 - x2) + Math.Abs(y1 - y2); }
public int[] DigArr(int n) { int[] ret = new int[Digit(n)]; ret.Length.REP(i => ret[i] = DigVal(n, i + 1)); return ret; }
public long DigArr2Num(IEnumerable<int> enu) { return enu.Aggregate((v, n) => v * 10 + n); }
public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; }
public int DigVal(int n, int dig) { return (n % (int)Pow(10, dig)) / (int)Pow(10, dig - 1); }
public long Tousa(long a, long d, long n) { return a + (n - 1) * d; }
public long TousaSum(long a, long d, long n) { return n * (2 * a + (n - 1) * d) / 2; }
public long[] enuDivsor(long N) {
var ret = new SortedSet<long>();
for (long i = 1; i * i <= N; i++)
if (N % i == 0) { ret.Add(i); ret.Add(N / i); }
return ret.ToArray();
}
public IEnumerable<int[]> enuP(int[] Arr, int Use = -1) {//列挙順列
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0 || Arr.Length < Use) yield break;
var s = new Stack<List<int>>();
Arr.Length.REPR(i => s.Push(new List<int>() { i }));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Count == Use) {
var ret = new List<int>(); cur.ForEach(X => ret.Add(Arr[X]));
yield return ret.ToArray();
} else
Arr.Length.REPR(i => { if (!cur.Contains(i)) s.Push(new List<int>(cur) { i }); });
}
}
public IEnumerable<int[]> enuC(int[] Arr, int Use = -1) {//列挙組み合わせ
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0 || Arr.Length < Use) yield break;
var s = new Stack<Tuple<int, List<int>>>();
Arr.Length.REPR(i => s.Push(Tuple.Create(i, new List<int>() { Arr[i] })));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item2.Count == Use) yield return cur.Item2.ToArray();
else for (int i = Arr.GetUpperBound(0); i > cur.Item1; i--)
s.Push(Tuple.Create(i, new List<int>(cur.Item2) { Arr[i] }));
}
}
public IEnumerable<int[]> enuDupP(int[] Arr, int Use = -1) {//列挙重複順列
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0) yield break; var s = new Stack<List<int>>();
Arr.Length.REPR(i => s.Push(new List<int>() { Arr[i] }));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Count == Use) yield return cur.ToArray();
else Arr.Length.REPR(i => s.Push(new List<int>(cur) { Arr[i] }));
}
}
public IEnumerable<int[]> enuDupC(int[] Arr, int Use = -1) {//列挙組み合わせ
Use = (Use != -1) ? Use : Arr.Length; if (Use == 0) yield break;
var s = new Stack<Tuple<int, List<int>>>();
Arr.Length.REPR(i => s.Push(Tuple.Create(i, new List<int>() { Arr[i] })));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item2.Count == Use) yield return cur.Item2.ToArray();
else for (int i = Arr.GetUpperBound(0); i >= cur.Item1; i--)
s.Push(Tuple.Create(i, new List<int>(cur.Item2) { Arr[i] }));
}
}
public IEnumerable<long[]> enuPart(string str) {
var s = new Stack<Tuple<string, List<long>, int>>();
s.Push(Tuple.Create(str[0].ToString(), new List<long>(), 1));
while (s.Count > 0) {
var cur = s.Pop();
if (cur.Item3 >= str.Length) yield return (new List<long>(cur.Item2) { cur.Item1.toLong() }).ToArray();
else {
s.Push(Tuple.Create(cur.Item1 + str[cur.Item3], new List<long>(cur.Item2), cur.Item3 + 1));
s.Push(Tuple.Create(str[cur.Item3].ToString(), new List<long>(cur.Item2) { cur.Item1.toLong() }, cur.Item3 + 1));
}
}
}
}
class Time {
public int[] M = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
public int[] D = { 31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
public Time() { D[1] = 28; }
public Time(int y) { D[1] = isLeapYear(y) ? 29 : 28; }
public bool isLeapYear(int y) { return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)); }
}
#endregion
#region Data
class AssociativeArray<T> : IEnumerable {
public Dictionary<T, int> dic;
public AssociativeArray() { dic = new Dictionary<T, int>(); }
public AssociativeArray(params T[] a) { dic = new Dictionary<T, int>(); Add(a); }
public void Add(T a) { if (!conK(a)) dic[a] = 0; dic[a]++; }
public void Add(params T[] a) { a.Length.REP(i => { if (!conK(a[i])) dic[a[i]] = 0; dic[a[i]]++; }); }
public void Set(T k, int v) { if (!dic.ContainsKey(k)) dic[k] = 0; dic[k] = v; }
public void Remove(params T[] a) { a.Length.REP(i => { if (conK(a[i])) dic.Remove(a[i]); }); }
public T[] Keys() { return dic.Keys.ToArray<T>(); }
public int Val(T k) { return (dic.ContainsKey(k)) ? dic[k] : 0; }
public int ValSum => dic.Values.Sum();
public int KeyNum => dic.Keys.Count;
public int MaxVal => dic.Values.Max();
public int MinVal => dic.Values.Min();
public T MaxKey => MaxK();
public T MinKey => MinK();
public T MaxK() { var maxV = MaxVal; return dic.First(d => d.Value == maxV).Key; }
public T MinK() { var minV = MinVal; return dic.First(d => d.Value == minV).Key; }
public bool conK(T k) { return dic.ContainsKey(k); }
public bool anyK(params T[] k) { return k.Any(key => conK(key)); }
public bool allK(params T[] k) { return k.All(key => conK(key)); }
public void Show() { foreach (var v in dic) { Console.WriteLine(v.Key + " : " + v.Value); } }
public IEnumerator GetEnumerator() { foreach (var kp in dic) yield return kp; }
public T[] ValueSortedKey(bool inc = true) {//test
return (inc ? (dic.OrderBy(kp => kp.Value)) : (dic.OrderByDescending(kp => kp.Value)))
.ThenBy(kp => kp.Key).ToDictionary(kp => kp.Key, kp => kp.Value).Keys.ToArray();
}
//:sort->array
}
class Index {
public int[] Comp(int[] bef) {
int[] aft = new int[bef.Length];
var tmp = bef.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);
aft = bef.Select(v => tmp[v]).ToArray();
return aft;
}
}
class TreeDis {//TODO:shortestPath
public List<Tuple<long, long>>[] g; public long[] a2other; private int type;
public TreeDis(int type = 0) { this.type = type; }//0->bfs,other->dfs
public void Init(long n) { g = new List<Tuple<long, long>>[n + 1]; g.Length.REP(i => g[i] = new List<Tuple<long, long>>()); }
public void Run(long[] a, long[] b) { a.Length.REP(i => { g[a[i]].Add(Tuple.Create(b[i], 1L)); g[b[i]].Add(Tuple.Create(a[i], 1L)); }); }
public void Run(long[] a, long[] b, long[] w) { a.Length.REP(i => { g[a[i]].Add(Tuple.Create(b[i], w[i])); g[b[i]].Add(Tuple.Create(a[i], w[i])); }); }
public long[] a2iArr(long a) { a2other = new long[g.Count()]; if (type == 0) BFS(a); else DFS(a); return a2other; }
private void BFS(long a) {
var q = new Queue<Tuple<long, long>>(); q.Enqueue(Tuple.Create(a, -1L));
while (q.Count > 0) {
var c = q.Dequeue();
foreach (var v in g[c.Item1]) {
if (v.Item1 == c.Item2) continue;
a2other[v.Item1] = a2other[c.Item1] + v.Item2; q.Enqueue(Tuple.Create(v.Item1, c.Item1));
}
}
}
private void DFS(long a) {
var s = new Stack<Tuple<long, long>>(); s.Push(Tuple.Create(a, -1L));
while (s.Count > 0) {
var c = s.Pop();
foreach (var v in g[c.Item1]) {
if (v.Item1 == c.Item2) continue;
a2other[v.Item1] = a2other[c.Item1] + v.Item2; s.Push(Tuple.Create(v.Item1, c.Item1));
}
}
}
}
class ShortestPath {
public long INF = (long)1e15; protected int I = -1; protected int V; protected int E; public long[] cost;
public List<Tuple<int, long>>[] Adj; protected bool isNonDir = true;
public void Init(int n) { I = n + 1; V = n; Adj = new List<Tuple<int, long>>[I]; I.REP(i => Adj[i] = new List<Tuple<int, long>>()); }
public void AddPath(int f, int t, long c) {
E++;
if (isNonDir) {
Adj[f].Add(Tuple.Create(t, c)); Adj[t].Add(Tuple.Create(f, c));
} else {
Adj[f].Add(Tuple.Create(t, c));
}
}
public void AddPath(int[] f, int[] t, long[] c) { f.Length.REP(i => AddPath(f[i], t[i], c[i])); }
}
class Dijkstra : ShortestPath {//隣接対応後検証不足,有向とか
public long MinCost(int f, int t) {
cost = new long[I]; cost.Set(INF); cost[f] = 0;
var pq = new PQueue<Tuple<int, long>>(); pq.Enqueue(Tuple.Create(f, 0L));//(from,cost)
while (pq.Count > 0) {
var cur = pq.Dequeue();
if (cost[cur.Item1] < cur.Item2) continue; Adj[cur.Item1].Count.REP(i => {
var tmp = Adj[cur.Item1][i];
if (cost[tmp.Item1] > cost[cur.Item1] + tmp.Item2) {
cost[tmp.Item1] = cost[cur.Item1] + tmp.Item2; pq.Enqueue(Tuple.Create(tmp.Item1, cost[tmp.Item1]));
}
});
}
return cost[t];
}
}
class BellmanFord : ShortestPath {
private bool[] neg;
public BellmanFord() { }
public BellmanFord(bool isNonDir) { this.isNonDir = isNonDir; }
public long MinCost(int f, int t) {
cost = new long[I]; cost.Set(INF); cost[f] = 0; neg = new bool[I];
for (int i = 0; i < I - 1; i++) {
I.REP(j => Adj[j].Count.REP(k => {
var cur = Adj[j][k];
if (cost[cur.Item1] > cost[j] + cur.Item2)
cost[cur.Item1] = cost[j] + cur.Item2;
}));
}
for (int i = 0; i < I; i++) {
I.REP(j => Adj[j].Count.REP(k => {
var cur = Adj[j][k];
if (cost[cur.Item1] > cost[j] + cur.Item2) {
cost[cur.Item1] = cost[j] + cur.Item2;
neg[cur.Item1] = true;
}
if (neg[j]) neg[cur.Item1] = true;
}));
}
return cost[t];
}
public bool loopExist() { return neg[I - 1]; }
}
class WarshallFloyd {//そのうちAdjとどっちがいいか...TODO:ジェネリック
private int E; private int INF = (int)1e9; public long[,] G;
public void Init(int n) { E = n + 1; G = new long[E, E]; G.Set(INF); E.REP(i => G[i, i] = 0); }
public void AddPath(int f, int t, long c) { G[f, t] = c; G[t, f] = c; }
public void AddPath(int[] f, int[] t) { f.Length.REP(i => AddPath(f[i], t[i], 1)); }
public void AddPath(int[] f, int[] t, long[] c) { f.Length.REP(i => AddPath(f[i], t[i], c[i])); }
public void Run() { G = MinCostArr(); }
public long[,] MinCostArr() { E.REP(i => E.REP(j => E.REP(k => G[j, k] = Math.Min(G[j, k], G[j, i] + G[i, k])))); return G; }
}
class UnionFind {
public long[] parent; public long[] depth; private int I;
public void Init(int n) { I = n + 1; parent = new long[I]; depth = new long[I]; I.REP(i => parent[i] = i); }
public long Find(long x) { return (parent[x] == x) ? x : parent[x] = Find(parent[x]); }
public void Unite(long x, long y) {
x = Find(x); y = Find(y); if (x == y) return;
if (depth[x] < depth[y]) parent[x] = y; else { parent[y] = x; if (depth[x] == depth[y]) depth[x]++; }
}
public bool Same(int a, int b) { return Find(a) == Find(b); }
public long Size(int x) { return depth[Find(x)]; }
}
class Kruskal : ShortestPath {//TODO:test,
public long Run() {
var L = Adj.Select((l, i) => Tuple.Create(i, l[i].Item1, l[i].Item2)).OrderBy(t => t.Item3).ToList();
//var li = new List<Tuple<int, int, long>>();
//I.REP(i =>{ foreach (var t in Adj[i]) li.Add(Tuple.Create(i, t.Item1, t.Item2));});
//li = li.OrderBy(t => t.Item3).ToList();//li = li.OrderByDescending(t => t.Item3).ToList();
var uf = new UnionFind(); uf.Init(V); long ret = 0;
foreach (var t in L) {
if (!uf.Same(t.Item1, t.Item2)) {
ret += t.Item3; uf.Unite(t.Item1, t.Item2);
}
}
return ret;
}
}
#endregion
#region Ex
static class StringEX {
public static string Reversed(this string s) { return string.Join("", s.Reverse()); }
public static string Repeat(this string s, int n) { return string.Concat(Enumerable.Repeat(s, n).ToArray()); }
public static int toInt(this string s) { int n; return (int.TryParse(s.TrimStart('0'), out n)) ? n : 0; }
public static int toInt(this char c) { return toInt(c.ToString()); }
public static int toInt(this char[] c) { return toInt(new string(c)); }
public static long toLong(this string s) { long n; return (long.TryParse(s.TrimStart('0'), out n)) ? n : (long)0; }
public static long toLong(this char c) { return toLong(c.ToString()); }
public static long toLong(this char[] c) { return toLong(new string(c)); }
public static string toString(this char[] c) { return new string(c); }
}
static class NumericEx {
public static string pad0<T>(this T v, int n) { return v.ToString().PadLeft(n, '0'); }
public static double RoundOff(this double v, int n) { return Math.Round(v, n - 1, MidpointRounding.AwayFromZero); }
public static bool Odd(this int v) { return v % 2 != 0; }
public static bool Odd(this long v) { return v % 2 != 0; }
public static void REP(this int v, Action<int> act) { for (int i = 0; i < v; ++i) act(i); }
public static void REPR(this int v, Action<int> act) { for (int i = v - 1; i >= 0; --i) act(i); }
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) { Array.Sort(a); return a; }
public static T[] SortR<T>(this T[] a) { Array.Sort(a); Array.Reverse(a); return a; }
public static void Set<T>(this T[] a, T v) { a.Length.REP(i => a[i] = v); }
public static void Set<T>(this T[,] a, T v) { a.GetLength(0).REP(i => a.GetLength(1).REP(j => a[i, j] = v)); }
}
static class BitEx {
public static bool Any(this BitArray b) { foreach (bool f in b) if (f) return true; return false; }
public static bool All(this BitArray b) { foreach (bool f in b) if (!f) return false; return true; }
public static bool None(this BitArray b) { return !Any(b); }
public static void Flip(this BitArray b, int index) { b.Set(index, !b.Get(index)); }
}
static class IEnumerableEx {
//
}
#endregion
} | a.cc:47:10: error: invalid preprocessing directive #region
47 | #region MockMacro
| ^~~~~~
a.cc:51:10: error: invalid preprocessing directive #endregion
51 | #endregion
| ^~~~~~~~~
a.cc:54:6: error: invalid preprocessing directive #region
54 | #region default
| ^~~~~~
a.cc:148:6: error: invalid preprocessing directive #endregion
148 | #endregion
| ^~~~~~~~~
a.cc:149:6: error: invalid preprocessing directive #region
149 | #region other
| ^~~~~~
a.cc:261:6: error: invalid preprocessing directive #endregion
261 | #endregion
| ^~~~~~~~~
a.cc:262:6: error: invalid preprocessing directive #region
262 | #region Data
| ^~~~~~
a.cc:420:6: error: invalid preprocessing directive #endregion
420 | #endregion
| ^~~~~~~~~
a.cc:421:6: error: invalid preprocessing directive #region
421 | #region Ex
| ^~~~~~
a.cc:456:6: error: invalid preprocessing directive #endregion
456 | #endregion
| ^~~~~~~~~
a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Collections.Generic;
| ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
4 | using System.Diagnostics;
| ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
5 | using System.IO;
| ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'System'
6 | using System.Linq;
| ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'System'
7 | using System.Linq.Expressions;
| ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'System'
8 | using System.Text;
| ^~~~~~
a.cc:13:13: error: expected unqualified-id before '[' token
13 | long[] v;
| ^
a.cc:42:15: error: expected ':' before 'static'
42 | public static void Main() { new MainClass().Stream(); }
| ^~~~~~~
| :
a.cc:43:9: error: 'IO' does not name a type
43 | IO io = new IO();
| ^~
a.cc:49:32: error: 'Action' has not been declared
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^~~~~~
a.cc:49:38: error: expected ',' or '...' before '<' token
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^
a.cc:50:33: error: 'Action' has not been declared
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^~~~~~
a.cc:50:39: error: expected ',' or '...' before '<' token
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^
a.cc:53:6: error: expected ';' after class definition
53 | }
| ^
| ;
a.cc: In member function 'void Program::MainClass::Solve()':
a.cc:15:13: error: 'io' was not declared in this scope
15 | io.i(out N, out A, out B);
| ^~
a.cc:15:18: error: 'out' was not declared in this scope
15 | io.i(out N, out A, out B);
| ^~~
a.cc:15:29: error: expected ')' before 'A'
15 | io.i(out N, out A, out B);
| ^
a.cc:15:17: note: to match this '('
15 | io.i(out N, out A, out B);
| ^
a.cc:15:36: error: expected ')' before 'B'
15 | io.i(out N, out A, out B);
| ^
a.cc:15:17: note: to match this '('
15 | io.i(out N, out A, out B);
| ^
a.cc:16:24: error: expected ')' before 'v'
16 | io.ini(out v, N);
| ^
a.cc:16:19: note: to match this '('
16 | io.ini(out v, N);
| ^
a.cc:17:13: error: 'Mat' was not declared in this scope
17 | Mat mat = new Mat();
| ^~~
a.cc:18:13: error: 'var' was not declared in this scope
18 | var C = mat.C(50);
| ^~~
a.cc:19:13: error: 'v' was not declared in this scope
19 | v.SortR();
| ^
a.cc:21:15: error: request for member 'REP' in '((Program::MainClass*)this)->Program::MainClass::A', which is of non-class type 'int'
21 | A.REP(i => maxAve += v[i]);
| ^~~
a.cc:21:19: error: 'i' was not declared in this scope
21 | A.REP(i => maxAve += v[i]);
| ^
a.cc:21:22: error: expected primary-expression before '>' token
21 | A.REP(i => maxAve += v[i]);
| ^
a.cc:24:17: error: expected ';' before 'top'
24 | var top = v.First();
| ^~~
a.cc:25:17: error: expected ';' before 'bot'
25 | var bot = v[A - 1];
| ^~~
a.cc:26:17: error: 'top' was not declared in this scope
26 | if (top != bot) {
| ^~~
a.cc:26:24: error: 'bot' was not declared in this scope
26 | if (top != bot) {
| ^~~
a.cc:27:21: error: expected ';' before 'indexedV'
27 | var indexedV = v.Select((e, i) => new { e, i });
| ^~~~~~~~
a.cc:27:63: error: expected primary-expression before ')' token
27 | var indexedV = v.Select((e, i) => new { e, i });
| ^
a.cc:28:21: error: expected ';' before 'choice'
28 | var choice = indexedV.Where(v => v.e == bot).Count();
| ^~~~~~
a.cc:29:21: error: expected ';' before 'choiced'
29 | var choiced = indexedV.Where(v => v.e == bot && v.i < A).Count();
| ^~~~~~~
a.cc:30:23: error: 'C' was not declared in this scope
30 | ans = C[choice, choiced];
| ^
a.cc:30:25: error: 'choice' was not declared in this scope
30 | ans = C[choice, choiced];
| ^~~~~~
a.cc:30:33: error: 'choiced' was not declared in this scope
30 | ans = C[choice, choiced];
| ^~~~~~~
a.cc:32:21: error: expected ';' before 'choice'
32 | var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
| ^~~~~~
a.cc:32:61: error: expected primary-expression before ')' token
32 | var choice = v.Select((e, i) => new { e, i }).Where(v => v.e == top).Count();
| ^
a.cc:34:25: error: 'choice' was not declared in this scope
34 | if (choice < i) break;
| ^~~~~~
a.cc:35:28: error: 'C' was not declared in this scope
35 | ans += C[choice, i];
| ^
a.cc:35:30: error: 'choice' was not declared in this scope
35 | ans += C[choice, i];
| ^~~~~~
a.cc: In static member function 'static void Program::MainClass::Main()':
a.cc:42:52: error: expected ';' before '.' token
42 | public static void Main() { new MainClass().Stream(); }
| ^
a.cc: In member function 'void Program::MainClass::Stream()':
a.cc:44:34: error: 'io' was not declared in this scope
44 | void Stream() { Solve(); io.writeFlush(); }
| ^~
a.cc: In member function 'void Program::MainClass::FOR(int, int, int)':
a.cc:49:79: error: 'act' was not declared in this scope
49 | void FOR(int a, int b, Action<int> act) { for (int i = a; i < b; ++i) act(i); }
| ^~~
a.cc: In member function 'void Program::MainClass::FORR(int, int, int)':
a.cc:50:85: error: 'act' was not declared in this scope
50 | void FORR(int a, int b, Action<int> act) { for (int i = a - 1; i >= b; --i) act(i); }
| ^~~
a.cc: At global scope:
a.cc:56:9: error: 'TYPE' does not name a type
56 | TYPE tp;
| ^~~~
a.cc:57:9: error: 'string' does not name a type
57 | string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
| ^~~~~~
a.cc:57:49: error: expected unqualified-id before '[' token
57 | string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
| ^
a.cc:58:9: error: 'StreamWriter' does not name a type
58 | StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
| ^~~~~~~~~~~~
a.cc:59:15: error: expected ':' before 'IO'
59 | public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); tp = new TYPE(); }
| ^~~
| :
a.cc:60:15: error: expected ':' before 'string'
60 | public string Next() {
| ^~~~~~~
| :
a.cc:60:16: error: 'string' does not name a type
60 | public string Next() {
| ^~~~~~
a.cc:68:15: error: expected ':' before 'string'
68 | public string String => Next();
| ^~~~~~~
| :
a.cc:68:16: error: 'string' does not name a type
68 | public string String => Next();
| ^~~~~~
a.cc:69:15: error: expected ':' before 'char'
69 | public char Char => char.Parse(String);
|
s233316934 | p03776 | C++ | #include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
//nCk
ll dp[51][51];
void comb(int N){
for(int i=0;i<=N;i++){
for(int j=0;j<=i;j++){
if(j==0||j==i){
dp[i][j]=1LL;
}else{
dp[i][j]=(dp[i-1][j-1]+dp[i-1][j]);
}
}
}
}
ll cal(int n,int k){
return dp[n][k];
}
int main(void){
int n,a,b;
cin>>n>>a>>b;
ll v[51];
map<ll,int>m;
m.clear();
for(int i=0;i<n;i++){
cin>>v[i];
m[v[i]]++;
}
sort(v,v+n,greater<int>());
ll sum=v[0];
ll pre=v[0];
bool sev=false;
vector<ll>num;
num.push_back(v[0]);
for(int i=1;i<a;i++){
if(v[i]!=pre)sev=true;
sum+=v[i];
num.push_back(v[i]);
}
//求める平均値
double ave=(double)sum/a;
ll ans=0;
comb(50);
if(sev){
//複数
ans=1;
for(int i=0;i<num.size();i++){
ans*=m[num[i]];
}
}else{
//1種類
for(int i=a;i<=b;i++){
ans+=cal(m[v[0]],i);
}
}
printf("%.6lf\n",ave);
cout<<ans<<endl;
return 0;
}
| a.cc:77:1: error: extended character is not valid in an identifier
77 |
| ^
a.cc:77:1: error: '\U00003000' does not name a type
77 |
| ^~
|
s392564376 | p03776 | C++ | #include "bits/stdc++.h"
using namespace std;
long long com[70][70]; //67以上でオーバーフロー
void init(int n) {
for (int i = 0; i <= n; i ++) {
for (int j = 0; j <= i; j ++) {
if (j == 0 || j == i) com[i][j] = 1LL;
else com[i][j] = com[i - 1][j - 1] + com[i - 1][j];
}
}
}
long long nCr(int n, int r) { return com[n][r]; }
int main() {
int n;
init(66);
cin >> n;
long long a, b;
cin >> a >> b;
vector<long long> v(n);
for (int i = 0; i < n; i ++) cin >> v[i];
sort(all(v));
reverse(all(v));
long long sum = 0;
long long mi;
for (int i = 0; i < a; i ++) {
sum += v[i];
if (i == a - 1) mi = v[i];
}
cout << setprecision(10) << (double)sum / (double)a << endl;
bool can_add = true;
for (int i = 0; i < a; i ++) if (v[i] != mi) can_add = false;
int cnt_A = 0, cnt_B = 0, cnt_all = 0;
for (int i = 0; i < a; i ++) if (v[i] == mi) cnt_A ++;
for (int i = 0; i < b; i ++) if (v[i] == mi) cnt_B ++;
for (int i = 0; i < n; i ++) if (v[i] == mi) cnt_all ++;
long long ans = 0;
for (int i = cnt_A; i <= (can_add ? cnt_B : cnt_A); i ++) ans += nCr(cnt_all, i);
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:14: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
23 | sort(all(v));
| ^~~
| std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
158 | all = 0777,
| ^~~
|
s003523035 | p03776 | C | #include<stdio.h>
#include<math.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ABS(a) ((a)>0 ? (a):-(a))
#define ll long long
#define SWAP(a,b) {a+=b;b=a-b;a-=b;}
int main(){
ll n,a,b,v[52];
double ave = 0;
ll numin = 0,numall = 0,num;
scanf("%lld %lld %lld",&n,&a,&b);
FOR(i,0,n) scanf("%lld",&v[i]);
FOR(i,0,n-1){
FOR(j,i+1,n)
if(v[i] < v[j]) SWAP(v[i],v[j]);
}
FOR(i,0,a) ave += v[i];
ave = ave/a;
FOR(j,0,a) if(v[j] == v[a-1]) numin ++;
FOR(j,0,n) if(v[j] == v[a-1]) numall ++;
num = FACT(numall) / FACT(numin) / FACT(numall - numin);
printf("%f %lld\n",ave,num);
} | main.c: In function 'main':
main.c:27:15: error: implicit declaration of function 'FACT' [-Wimplicit-function-declaration]
27 | num = FACT(numall) / FACT(numin) / FACT(numall - numin);
| ^~~~
|
s121532712 | p03776 | C++ | //start of jonathanirvings' template v3.0.3 (BETA)
#include <bits/stdc++.h>
using namespace std;
/**
using std::max; using std::swap; using std::abs; using std::priority_queue; using std::queue; using std::bitset; using std::make_tuple;
using std::istream; using std::ostream; using std::fixed; using std::greater; using std::tuple; using std::tie; using std::make_pair;
using std::cout; using std::cerr; using std::endl; using std::lower_bound; using std::upper_bound; using std::deque; using std::min;
using std::map; using std::string; using std::fill; using std::copy; using std::sort; using std::unique; using std::unordered_set;
using std::multiset; using std::nth_element; using std::min_element; using std::max_element; using std::vector; using std::set;
using std::unordered_map; using std::pair; using std::next_permutation; using std::reverse; using std::rotate; using std::cin;
using std::iota; using std::function; using std::shuffle; using std::iter_swap;
int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
const ll INF = 1e18;
*/
typedef long double ld;
typedef unsigned int uint;
typedef complex<double> P;
typedef unsigned char byte;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const ll moder = 1e9+7;
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
#ifdef TESTING
#define DEBUG fprintf(stderr,"====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif
// nichijou
// data type
#define fi first
#define se second
#define _1 first
#define _2 second
// STL container
#define ALL(a) (a).begin(), (a).end()
#define All(s) (s).begin(),(s).end()
#define rAll(s) (s).rbegin(),(s).rend()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define mp make_pair
#define pb push_back
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
#define FO(x, n) for (int x = 0; x < n; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define FOR(i,a,b) for(int _b=(b),(i)=(a);(i)<_b;++(i))
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
//#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define ROF(i,b,a) for(int _a=(a),i=(b);i>_a;--i)
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define FOR_ITER(x, a) for(auto (x) = (a).begin(); (x) != (a).end(); ++(x))
#define REPN(i,n) FORN(i,1,n)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define ALLA(arr,sz) arr,arr+sz
#define SZ(X) ((int)(X).size())
#define SIZE(X) ((int)(X).size())
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define nl '\n'
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
#define cout1(a) cout<<(a)<<endl
#define cout2(a,b) cout<<(a)<<" "<<(b)<<endl
#define cout3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
for (int c = 0; *s && (c || *s != ','); ++s) {
cerr<<*s;
switch (*s) {
case '(':
case '[':
case '{':
++c;
break;
case ')':
case ']':
case '}':
--c;
break;
}
}
cerr<<" = "<<a;
if (*s) {
cerr<<", ";
_BG(++s,b...);
} else
cerr<<endl;
}
#define BG(...) do { \
cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)
/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}
template<typename T, typename ... TT>
bool RD(T & a, TT & ... b) {return RD(a) && RD(b...);}
/* Do princesses dream of magic sheep? */
#define RI(a) RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)
#define DRI(a) int a; RD(a)
#define DRII(a,b) RI(a); RI(b)
#define DRIII(a,b,c) RI(a); RII(b,c)
#define DRIIII(a,b,c,d) RI(a); RIII(b,c,d)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}
/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ... b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}
/* Good Luck && Have Fun ! */
inline string IntToString(LL a){
char x[100];
sprintf(x,"%lld",a); string s = x;
return s;
}
inline LL StringToInt(string a){
char x[100]; LL res;
strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
return res;
}
inline string GetString(void){
char x[1000005];
scanf("%s",x); string s = x;
return s;
}
inline string uppercase(string s){
int n = SIZE(s);
RP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
return s;
}
inline string lowercase(string s){
int n = SIZE(s);
RP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
return s;
}
inline void OPEN (string s) {
#ifndef TESTING
freopen ((s + ".in").c_str (), "r", stdin);
freopen ((s + ".out").c_str (), "w", stdout);
#endif
}
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }
//ll rnd(ll x, ll y) { static auto gen = std::bind(std::uniform_int_distribution<ll>(), std::mt19937); return gen() % (y - x + 1) + x; }
bool is_prime(ll x) { if (x <= 1) return 0; for (ll y = 2; y * y <= x; ++y) if (x % y == 0) return 0; return 1; }
ll sqr(int a) { return (ll) a * a; } ld sqr(ld a) { return a * a; } ll sqr(ll a) { return a * a; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}
template<class Int, Int mod>
class ModInt {
public:
Int x;
ModInt(): x(0) {}
ModInt(int a, bool m=1) { if(m) {x=a%mod; if(x<0)x+=mod;} else x=a; }
ModInt(LL a, bool m=1) { if(m) {x=a%mod; if(x<0)x+=mod;} else x=a; }
inline ModInt &operator+=(ModInt that) { if((x += that.x) >= mod) x -= mod; return *this; }
inline ModInt &operator-=(ModInt that) { if((x += mod - that.x) >= mod) x -= mod; return *this; }
inline ModInt &operator*=(ModInt that) { x = LL(x) * that.x % mod; return *this; }
inline ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
inline ModInt operator-() const { return ModInt(-this->x); }
ModInt inverse() const {LL a=x,b=mod,u=1,v=0;while(b){LL t=a/b;a-=t*b;u-=t*v;swap(a,b);swap(u,v);} return ModInt(u);}
inline friend ostream& operator << (ostream &out, ModInt m) {return out << m.x;}
#define op(o1,o2) ModInt operator o1(ModInt that) const { return ModInt(*this) o2 that; }
op(+,+=) op(-,-=) op(*,*=) op(/,/=)
#undef op
#define op(o) bool operator o(ModInt that) const { return x o that.x; }
op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};
typedef ModInt<ll,1e18+7> Mint;
#define MAXN (300005)
Mint F[MAXN];
Mint FI[MAXN];
Mint Cnr(int n, int r)
{
if(r < 0 || r > n) return 0;
return F[n] * FI[r] * FI[n-r];
}
// spnauT
//end of jonathanirvings' template v3.0.3 (BETA)
int main(){
// int N, A;
// cin >> N >> A;
//
// vector<int> xs(N);
//
// FO(i, N) {
// cin >> xs.at(i);
// }
// IO();
F[0] = 1;
FOR(i,1,MAXN) F[i] = F[i-1] * i;
FI[MAXN-1] = F[MAXN-1].inverse();
ROF(i,MAXN-2,-1) FI[i] = FI[i+1] * (i+1);
//
// cint2(H,W);
// cint2(A,B);
// Mint sol;
// FOR(i,B+1,W+1) sol += Cnr(i-1+H-A-1, i-1) * Cnr(A-1+W-i, A-1);
//
// cout << sol << nl;
cint3(N, A, B);
vl ns(N);
map<ll, int> cnts;
FO(i, N) {
cin >> ns.at(i);
cnts[ns.at(i)]++;
}
sort(All(ns));
double avg = 0.;
int num = A;
FOR(i, A, B + 1) {
double avg0 = (double) accumulate(ns.rbegin(), ns.rbegin() + i, 0ll) / i;
if (avg < 1e-6) {
avg = avg0;
} else if (avg - avg0 > 1e-6) {
break;
} else {
num = i;
}
}
ll rs = 0;
FOR (i, A, num + 1) {
map<ll, int> s;
FOR(j, N - i, N) {
s[ns.at(j)] += 1;
}
ll r = 1;
FOR_ITER(it, s) {
ll t = it->fi;
Mint mt = Cnr(cnts[t], it->se);
r *= mt.x;
}
rs += r;
}
printf("%.6f\n%lld\n", avg, rs);
return 0;
}
/**
//#include <fcntl.h>
void solve() {
}
int main() {
//freopen("", "r", stdin);
//freopen("", "w", stdout);
cout.precision(15);
cout << fixed;
cerr.precision(6);
cerr << fixed;
solve();
#ifdef LOCAL
cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}
*/
/**
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cstdarg>
#include <cstdio>
#include <cmath>
#include <numeric>
#include <utility>
// #include "ane.cpp"
#define INF (int)1e9
#define INFLL (long long)1e18
#define NMAX 100005
#define MMAX 100005
#define MOD 100000
using namespace std;
// コメントアウトするとdebug()を実行しない
// #define DEBUG
//
// ライブラリ
//
// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<vec> mat;
// frequent used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};
// デバッグ用printf
void debug(const char* format, ...){
#ifndef DEBUG
return;
#endif
va_list arg;
va_start(arg, format);
vprintf(format, arg); // コンソールに出力
va_end(arg);
}
// n次元配列の初期化。第2引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
std::fill( (T*)array, (T*)(array+N), val );
}
// Union-Find Tree
class UnionFindTree{
struct node{
int par;
};
std::vector<node> T;
public:
void init(int num){
T.resize(num+1); // ignore T[0]
for (int i = 1; i <= num; ++i)
{
T[i].par = i;
}
}
void unite(int x, int y){
T[find(y)].par = find(x);
}
int find(int x){
if (T[x].par == x) return x;
else return T[x].par = find(T[x].par);
}
bool same(int x, int y){
return find(x) == find(y);
}
};
// Segment Tree for Range Minimum Query
// **********************************************************
// *** important: all functions' variable, ***
// *** such as "index", "l", "r", etc., must be 0-origin. ***
// **********************************************************
// ********************************************
// *** important: NMAX must be power of 2. ***
// ********************************************
template<typename T>
class SegmentTree{
private:
ll N;
T INF_VAL;
T dat[NMAX * 2]; // 0 origin, A[i] = dat[i + N]
T _query(ll l, ll r, ll l_resp, ll r_resp, ll i_dat){
debug("query(%lld, %lld, %lld, %lld, %lld) called\n",
l, r, l_resp, r_resp, i_dat);
if (r < l_resp || r_resp < l) return INF_VAL;
else if(l <= l_resp && r_resp <= r) return dat[i_dat];
else return min(_query(l ,r, l_resp, (l_resp + r_resp) / 2, i_dat * 2),
_query(l, r, (l_resp + r_resp) / 2 + 1, r_resp, i_dat * 2 + 1));
}
public:
void init(ll _N, T _inf_val){
N = 1; while(N < _N) N *= 2;
INF_VAL = _inf_val;
Fill(dat, _inf_val);
}
T get(ll index){
return dat[index + N];
}
void set(int index, T val){
int i_dat = index + N;
dat[i_dat] = val;
for (i_dat /= 2; i_dat > 0; i_dat /= 2)
{
dat[i_dat] = min(dat[i_dat * 2], dat[i_dat * 2 + 1]);
}
}
T query(ll l, ll r){
return _query(l, r, 0, N - 1, 1);
}
void dump(){
cout << "*** SegTree dump begin ***\n";
cout << "N = " << N << ", INF_VAL = " << INF_VAL << endl;
for (int i = 1; i < N * 2; i *= 2)
{
for (int j = i; j < i * 2; ++j)
{
if(dat[j] == INF_VAL) cout << "INF ";
else cout << dat[j] << " ";
}
cout << endl;
}
cout << "*** SegTree dump end ***\n";
}
};
// Binary Indexed Tree for Range Sum Query
// *******************************************
// *** important: all functions' variable, ***
// *** such as "i", must be 1-origin. ***
// *******************************************
template<typename T>
class BinaryIndexedTree{
private:
ll N;
T dat[NMAX + 1]; // 1 origin, A[i] = sum(i) - sum(i-1)
public:
void init(ll _N){
N = _N;
Fill(dat, 0);
}
void add(int i, T val){
while(i <= N) {
dat[i] += val;
i += i & -i;
}
}
T sum(ll i){
T ret = 0;
while(i > 0) {
ret += dat[i];
i -= i & -i; // set last HIGH bit to LOW
}
return ret;
}
T sum(ll left, ll right){
return sum(right) - sum(left - 1);
}
void dump(){
cout << "*** BITree dump begin ***\n";
cout << "N = " << N << endl;
for (int i = 1; i <= N; i *= 2)
{
cout << dat[i] << " ";
}
cout << "*** BITree dump end ***\n";
}
};
//
// ライブラリ終了
//
*/
| a.cc:284:23: error: conversion from 'double' to 'long long int' in a converted constant expression
284 | typedef ModInt<ll,1e18+7> Mint;
| ~~~~^~
a.cc:284:23: error: could not convert '(1.0e+18 + (double)7)' from 'double' to 'long long int'
284 | typedef ModInt<ll,1e18+7> Mint;
| ~~~~^~
| |
| double
a.cc: In function 'int main()':
a.cc:312:32: error: request for member 'inverse' in 'F[300004]', which is of non-class type 'Mint' {aka 'int'}
312 | FI[MAXN-1] = F[MAXN-1].inverse();
| ^~~~~~~
a.cc:357:21: error: request for member 'x' in 'mt', which is of non-class type 'Mint' {aka 'int'}
357 | r *= mt.x;
| ^
|
s319157408 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;
#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define LL long long
#define ULL unsigned long long
// n개중에서 k 를 고르는 Combination table을 미리 세팅한다.
// C[n][k] -> nCk
ULL Comb[51][51];
void combination_table(int n)
{
for(int i = 0; i <= n; ++i)
for(int j = 0; j <= i; ++j)
{
if(j == 0 || j == i)
Comb[i][j] = 1ll;
else
Comb[i][j] = Comb[i - 1][j - 1] + Comb[i - 1][j];
}
}
LL cache[51][51];
LL bino2(int n, int r)
{
if(r > n) return 0;
if(r == 0 || n == r) return 1;
int& ret = cache[n][r];
if(ret != -1)
return ret;
return ret = (bino2(n - 1, r - 1) + bino2(n - 1, r));
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifndef ONLINE_JUDGE
//freopen("tmp.in", "r", stdin);
// freopen("tmp.out", "w", stderr);
#endif
int N, A, B;
cin >> N >> A >> B;
VL items(N, 0);
REP(i, 0, N) cin >> items[i];
combination_table(N);
sort(items.begin(), items.end(), greater<LL>());
double max_avg = (double)accumulate(items.begin(), items.begin() + A, 0ll) / A;
int num = 0, pos = 0;
REP(i, 0, N){
if(items[i] == items[A - 1])
{
++num;
if(i < A)
++pos;
}
}
CLEAR(cache, -1);
LL cnt = 0ll;
if(pos == A)
{
for(int i = A; i <= B; ++i)
cnt += bino2(num, i);
}
else
cnt += bino2(num, pos);
cout.precision(10);
cout << fixed << max_avg << endl << cnt << endl;
return 0;
} | a.cc: In function 'long long int bino2(int, int)':
a.cc:42:26: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
42 | int& ret = cache[n][r];
| ~~~~~~~~~~^
|
s708009525 | p03776 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(double i=a;i<b;i++)
long long comb(int n, int i) {
if (n - i < i) i = n - i;
long long k = 1;
for (int d = 1; d <= i; ++d) {
k *= n--;
k /= d;
}
return k;
}
int main() {
double n, a, b;
long long v[52], cnt = 0, key = 0;
double avr = 0;
cin >> n >> a >> b;
rep(i, 0, n) {
cin >> v[i];
}
sort(v,v+n);
reverse(v,v+n);
rep(i, 0, a) {
avr += v[i];
}
avr /= a;
rep(i, a, b+1) {
double avr_b = 0;
rep(j, 0, i) {
avr_b += v[j];
}
avr_b /= i;
//cout << i << endl;
if (avr_b != avr)continue;
key = v[i-1];
//cout << key << " key" << endl;
int keyp = find(begin(v), end(v), key) - v;
//cout << keyp <<" keyp"<< endl;
int min_exp = i - keyp;
int min_count = count(v, v + n, key);
//cout << min_exp<<" "<<min_count << endl;
cnt += comb(min_count, min_exp);
//cout << cnt << endl;
}
cout << avr << endl;
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:21:25: error: invalid types 'long long int [52][double]' for array subscript
21 | cin >> v[i];
| ^
a.cc:23:17: error: invalid operands of types 'long long int [52]' and 'double' to binary 'operator+'
23 | sort(v,v+n);
| ~^~
| | |
| | double
| long long int [52]
a.cc:24:20: error: invalid operands of types 'long long int [52]' and 'double' to binary 'operator+'
24 | reverse(v,v+n);
| ~^~
| | |
| | double
| long long int [52]
a.cc:26:25: error: invalid types 'long long int [52][double]' for array subscript
26 | avr += v[i];
| ^
a.cc:33:27: error: invalid types 'long long int [52][double]' for array subscript
33 | avr_b += v[j];
| ^
a.cc:38:24: error: invalid types 'long long int [52][double]' for array subscript
38 | key = v[i-1];
| ^
a.cc:43:44: error: invalid operands of types 'long long int [52]' and 'double' to binary 'operator+'
43 | int min_count = count(v, v + n, key);
| ~ ^ ~
| | |
| | double
| long long int [52]
|
s959495989 | p03776 | C++ | long long comb(int n, int i) {
if (n - i < i) i = n - i;
long long k = 1;
for (int d = 1; d <= i; d++) {
k *= n--;
k /= d;
}
return k;
}
int main() {
int n, a, b;
long long v[52], cnt = 0,key=0;
double avr = 0;
cin >> n >> a >> b;
rep(i, 0, n) {
cin >> v[i];
}
sort(v,v+n);
reverse(v,v+n);
rep(i, 0, a) {
avr += v[i];
}
avr /= a;
rep(i, a, b+1) {
double avr_b = 0;
rep(j, 0, i) {
avr_b += v[j];
}
avr_b /= i;
if (avr_b != avr)continue;
key = v[i-1];
int keyp = find(begin(v), end(v), key) - v;
//cout << keyp <<" key_first"<< endl;
int min_count = count(v, v + n, key);
int min_exp = i - keyp;
//cout << min_exp<<" "<<min_count << endl;
cnt += comb(min_count, min_exp);
//cout << cnt << endl;
}
cout << avr << endl;
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:15:9: error: 'cin' was not declared in this scope
15 | cin >> n >> a >> b;
| ^~~
a.cc:16:13: error: 'i' was not declared in this scope
16 | rep(i, 0, n) {
| ^
a.cc:16:9: error: 'rep' was not declared in this scope
16 | rep(i, 0, n) {
| ^~~
a.cc:19:9: error: 'sort' was not declared in this scope; did you mean 'short'?
19 | sort(v,v+n);
| ^~~~
| short
a.cc:20:9: error: 'reverse' was not declared in this scope
20 | reverse(v,v+n);
| ^~~~~~~
a.cc:43:9: error: 'cout' was not declared in this scope
43 | cout << avr << endl;
| ^~~~
a.cc:43:24: error: 'endl' was not declared in this scope
43 | cout << avr << endl;
| ^~~~
|
s283413229 | p03776 | Java |
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main_1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int MIN = sc.nextInt();
int MAX = sc.nextInt();
BigInteger[][] combo_table = new BigInteger[N+1][N+1];
setConbTable(combo_table);
BigInteger[] values = new BigInteger[N];
for(int i = 0;i < N;i++){
values[i] = sc.nextBigInteger();
}
Arrays.sort(values, new Comparator<BigInteger>() {
public int compare(BigInteger x,BigInteger y){
return Integer.valueOf(y.subtract(x).toString());
}
});
BigInteger sum = BigInteger.ZERO;
for(int i = 0;i < MIN;i++){
sum = sum.add(values[i]);
}
System.out.println(String.format("%f", sum.doubleValue() / MIN));
BigInteger pattern_count = BigInteger.ZERO;
if(values[0].equals(values[MIN - 1])){
int min_value_count = MIN;
for(int i = MIN;i < MAX;i++){
if(!values[0].equals(values[i]))break;
min_value_count++;
}
for(int i = MIN;i <= MAX;i++){
// System.out.println("min : " + min_value_count + ", i : " + i);
if(!values[i - 1].equals(values[0]))break;
pattern_count = pattern_count.add(combo_table[min_value_count][i]);
}
}else{
int min_value_count = 0;
int inner_count = 0;
for(int i = MIN - 1;0 <= i;i--){
if(!values[MIN - 1].equals(values[i]))break;
min_value_count++;
inner_count++;
}
for(int i = MIN; i < N;i++){
if(!values[MIN - 1].equals(values[i]))break;
min_value_count++;
}
pattern_count = pattern_count.add(combo_table[min_value_count][inner_count]);
}
System.out.println(pattern_count);
sc.close();
}
static BigInteger factrial(BigInteger num){
if(num.compareTo(BigInteger.ONE) < 0)return BigInteger.ONE;
return num.multiply(factrial(num.subtract(BigInteger.ONE)));
}
static void setConbTable(BigInteger[][]table){
for(int i = 0;i < table.length;i++){
for(int j = 0;j <= i; j++){
if(j == 0 || j == i){
table[i][j] = BigInteger.ONE;
}else{
table[i][j] = table[i-1][j-1].add(table[i-1][j]);
}
}
}
}
}
| Main.java:8: error: class Main_1 is public, should be declared in a file named Main_1.java
public class Main_1 {
^
1 error
|
s291332080 | p03776 | C++ | #include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int long long int;
#define MOD (1e9+7);
#define INF (2e9)
long long int c(int x, int y) {//xCyを返す関数
long long int a = 1;
for (int i = 1; i<=y; i++) {
a *= x+1-i;//x,x-1,・・・,x-y+1 がaにかけられる
a/=i;//1,2,・・・,y をaから割る
}
return a;
}
int main(void) {
int n, a, b;
cin >> n >> a >> b;
long long int *v = new long long int[n];
for (int i = 0; i<n; i++) {
cin >> v[i];
}
sort(v, v + n);
reverse(v, v + n);
long long int min = v[a-1];
//min = 価値平均が最大となるように選んだ品物のうち、
// 一番価値の低いものの価値 →
long long int ans = 0;//答え(場合の数)
double ans_max=0;//答え(最大値)
if (v[0] == min) {//A番目まですべて同じ価値なら
ans_max=min;// 答え
int i;
for (i = 0; i<n; i++) {
if (v[i] != min) {//{min,min,・・・,min,no,・・・} ならばnoを指して止まる
break;
}
}
//i = min と同じ価値の品物の個数
while (a <= b && a <= i) {//i個のうちa個選ぶ、a+1個選ぶ、・・・・、min(b,i)個選ぶ
ans += c(i, a);
a++;
}
}
else {
for(int k=0;k<a;k++){//A番目までの商品の平均値
ans_max+=v[k];
}
ans_max/=a;
int minp, minm;
for (minp = a-1; v[minp] == min && minp<n; minp++) {}//minより小さい値を見つけたらstop
for (minm = a-1; v[minm] == min &&minm >= 0; minm--) {}
int kosu = minp - minm - 1;
a -= n - minp;
ans = c(kosu, a);
}
cout << ans_maxp<<"\n"<<ans << "\n";
return 0;
} | a.cc:5:23: error: 'long long long' is too long for GCC
5 | typedef long long int long long int;
| ^~~~
a.cc:5:28: error: 'long long long' is too long for GCC
5 | typedef long long int long long int;
| ^~~~
a.cc:5:19: error: multiple types in one declaration
5 | typedef long long int long long int;
| ^~~
a.cc:5:33: error: declaration does not declare anything [-fpermissive]
5 | typedef long long int long long int;
| ^~~
a.cc: In function 'int main()':
a.cc:66:13: error: 'ans_maxp' was not declared in this scope; did you mean 'ans_max'?
66 | cout << ans_maxp<<"\n"<<ans << "\n";
| ^~~~~~~~
| ans_max
|
s567076566 | p03776 | C++ | include <stdio>
using ll=long long;
using R=double;
using namespace std;
// Combination Table
ll C[51][51]; // C[n][k] -> nCk
void comb_table(int N){
for(int i=0;i<=N;++i){
for(int j=0;j<=i;++j){
if(j==0 or j==i){
C[i][j]=1LL;
}else{
C[i][j]=(C[i-1][j-1]+C[i-1][j]);
}
}
}
}
int main(void){
int N,A,B;
cin >> N >> A >> B;
const int NMAX=50;
ll v[NMAX];
for(int i=0;i<N;++i){
cin >> v[i];
}
comb_table(N);
sort(v,v+N);
reverse(v,v+N);
R max_average=0.0;
for(int i=0;i<A;++i){
max_average+=v[i];
}
max_average/=A;
int a_th_val_num=0,a_th_val_pos=0;
for(int i=0;i<N;++i){
if(v[i]==v[A-1]){
a_th_val_num++;
if(i<A){
a_th_val_pos++;
}
}
}
ll cnt=0LL;
if(a_th_val_pos==A){
for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
cnt+=C[a_th_val_num][a_th_val_pos];
}
}else{
cnt+=C[a_th_val_num][a_th_val_pos];
}
cout.precision(20);
cout << fixed << max_average << endl;
cout << cnt << endl;
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include <stdio>
| ^~~~~~~
a.cc:7:2: error: 'll' does not name a type
7 | ll C[51][51]; // C[n][k] -> nCk
| ^~
a.cc: In function 'void comb_table(int)':
a.cc:13:2: error: 'C' was not declared in this scope
13 | C[i][j]=1LL;
| ^
a.cc:15:2: error: 'C' was not declared in this scope
15 | C[i][j]=(C[i-1][j-1]+C[i-1][j]);
| ^
a.cc: In function 'int main()':
a.cc:23:2: error: 'cin' was not declared in this scope
23 | cin >> N >> A >> B;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | include <stdio>
a.cc:26:2: error: 'll' was not declared in this scope
26 | ll v[NMAX];
| ^~
a.cc:29:9: error: 'v' was not declared in this scope
29 | cin >> v[i];
| ^
a.cc:33:7: error: 'v' was not declared in this scope
33 | sort(v,v+N);
| ^
a.cc:33:2: error: 'sort' was not declared in this scope; did you mean 'short'?
33 | sort(v,v+N);
| ^~~~
| short
a.cc:34:2: error: 'reverse' was not declared in this scope
34 | reverse(v,v+N);
| ^~~~~~~
a.cc:52:4: error: expected ';' before 'cnt'
52 | ll cnt=0LL;
| ^~~~
| ;
a.cc:55:2: error: 'cnt' was not declared in this scope; did you mean 'int'?
55 | cnt+=C[a_th_val_num][a_th_val_pos];
| ^~~
| int
a.cc:55:7: error: 'C' was not declared in this scope
55 | cnt+=C[a_th_val_num][a_th_val_pos];
| ^
a.cc:58:2: error: 'cnt' was not declared in this scope; did you mean 'int'?
58 | cnt+=C[a_th_val_num][a_th_val_pos];
| ^~~
| int
a.cc:58:7: error: 'C' was not declared in this scope
58 | cnt+=C[a_th_val_num][a_th_val_pos];
| ^
a.cc:61:2: error: 'cout' was not declared in this scope
61 | cout.precision(20);
| ^~~~
a.cc:61:2: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:62:10: error: 'fixed' was not declared in this scope
62 | cout << fixed << max_average << endl;
| ^~~~~
a.cc:1:1: note: 'std::fixed' is defined in header '<ios>'; this is probably fixable by adding '#include <ios>'
+++ |+#include <ios>
1 | include <stdio>
a.cc:62:34: error: 'endl' was not declared in this scope
62 | cout << fixed << max_average << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | include <stdio>
a.cc:63:10: error: 'cnt' was not declared in this scope; did you mean 'int'?
63 | cout << cnt << endl;
| ^~~
| int
|
s940792778 | p03776 | Java | import java.math.BigInteger;
import java.lang.Object;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
public class d {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int l = sc.nextInt();
int r = sc.nextInt();
Long[] a = new Long[n];
for (int i = 0; i < n; i++) {
a[i] = new Long(sc.nextLong());
}
Arrays.sort(a);
Collections.reverse(Arrays.asList(a));
BigInteger c[][] = new BigInteger[60][60];
for (int i = 0; i < 60; i++) {
for (int j = 0; j < 60; j++) {
c[i][j] = BigInteger.ZERO;
}
}
c[0][0] = BigInteger.ONE;
for (int i = 0; i < 59; i++) {
for (int j = 0; j < 59; j++) {
c[i + 1][j] = c[i + 1][j].add(c[i][j]);
c[i + 1][j + 1] = c[i + 1][j + 1].add(c[i][j]);
}
}
int x = l;
int y = l;
while (x > 0 && a[x-1].equals(a[x])) x--;
while (y + 1 < n && a[y+1].equals(a[y])) y++;
BigInteger cnt = BigInteger.ZERO;
int all = y - x + 1;
if (x == 0) {
for (int i = l; i <= r; i++) {
cnt = cnt.add(c[all][i]);
}
} else {
cnt = c[all][l-x+1];
}
long sum = 0;
for (int i = 0; i < l; i++) {
sum += a[i];
}
System.out.format("%.10f\n", (double) sum / l);
System.out.println(cnt);
}
}
| Main.java:7: error: class d is public, should be declared in a file named d.java
public class d {
^
Main.java:18: warning: [removal] Long(long) in Long has been deprecated and marked for removal
a[i] = new Long(sc.nextLong());
^
1 error
1 warning
|
s460681089 | p03776 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
using namespace std;
long long comb(int n, int k) {
long long s1 = 1, s2 = 1;
for (i = (n-k+1); i <= n; i++)
s1 *= i;
for (i = 1; i <= k; i++)
s2 *= i;
return s1/s2;
}
int main()
{
int N, A, B;
long long t, ans = 0;
int X, Y;
vector<long long> v(51);
cin >> N >> A >> B;
for(int i = 0; i < N; i++)
cin >> v[i];
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
t = v[A-1];
X = count(v.begin(), v.end(), t);
Y = count(v.begin(), v.begin()+A, t);
if (v[0] != v[A-1])
ans = comb(X, Y);
else {
for (int i = A; i <= B; i++) {
if (i <= X)
ans += comb(X, i);
}
}
cout << setprecision(10) << (accumulate(v.begin(), v.begin()+A, 0.0)) / A << endl;
cout << ans << endl;
return 0;
} | a.cc: In function 'long long int comb(int, int)':
a.cc:11:10: error: 'i' was not declared in this scope
11 | for (i = (n-k+1); i <= n; i++)
| ^
a.cc:13:10: error: 'i' was not declared in this scope
13 | for (i = 1; i <= k; i++)
| ^
|
s673849506 | p03776 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
using namespace std;
long long comb(n, k) {
long long s1 = 1, s2 = 1;
for (i = (n-k+1); i <= n; i++)
s1 *= i;
for (i = 1; i <= k; i++)
s2 *= i;
return s1/s2;
}
int main()
{
int N, A, B;
long long t, ans = 0;
int X, Y;
vector<long long> v(51);
cin >> N >> A >> B;
for(int i = 0; i < N; i++)
cin >> v[i];
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
t = v[A-1];
X = count(v.begin(), v.end(), t);
Y = count(v.begin(), v.begin()+A, t);
if (v[0] != v[A-1])
ans = comb(X, Y);
else {
for (int i = A; i <= B; i++) {
if (i <= X)
ans += comb(X, i);
}
}
cout << setprecision(10) << (accumulate(v.begin(), v.begin()+A, 0.0)) / A << endl;
cout << ans << endl;
return 0;
} | a.cc:9:16: error: 'n' was not declared in this scope
9 | long long comb(n, k) {
| ^
a.cc:9:19: error: 'k' was not declared in this scope
9 | long long comb(n, k) {
| ^
a.cc:9:20: error: expression list treated as compound expression in initializer [-fpermissive]
9 | long long comb(n, k) {
| ^
a.cc: In function 'int main()':
a.cc:40:19: error: 'comb' cannot be used as a function
40 | ans = comb(X, Y);
| ~~~~^~~~~~
a.cc:44:28: error: 'comb' cannot be used as a function
44 | ans += comb(X, i);
| ~~~~^~~~~~
|
s507794153 | p03776 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Dell on 28-03-2017.
*/
public class TaskB {
static void solve(Long[] numbers, int a, int b) {
Arrays.sort(numbers, Collections.reverseOrder());
HashMap<Long, Integer> freqMap = new HashMap<>();
Arrays.stream(numbers).forEach(num -> freqMap.put(num, freqMap.getOrDefault(num, 0) + 1));
Map<Long, Integer> candidateMap = new HashMap<>();
for (int i = 0; i < a; i++) {
candidateMap.put(numbers[i], candidateMap.getOrDefault(numbers[i], 0) + 1);
}
long ways = 1L;
for (Map.Entry<Long, Integer> entry : candidateMap.entrySet()) {
ways *= freqMap.get(entry.getKey()) / entry.getValue();
}
double mean = 0.0d;
for (int i = 0; i < a; i++) {
mean += numbers[i];
}
mean /= a;
System.out.printf("%.06f\n", mean);
System.out.println(ways);
}
static Integer[] readIntArray(BufferedReader br) throws IOException {
String s = br.readLine();
String[] tokens = s.trim().split(" +");
Integer[] array = new Integer[tokens.length];
for (int i = 0; i < tokens.length; i++) {
array[i] = Integer.valueOf(tokens[i]);
}
return array;
}
static Long[] readLongArray(BufferedReader br) throws IOException {
String s = br.readLine();
String[] tokens = s.trim().split(" +");
Long[] array = new Long[tokens.length];
for (int i = 0; i < tokens.length; i++) {
array[i] = Long.valueOf(tokens[i]);
}
return array;
}
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
Integer[] nab = readIntArray(br);
Long[] array = readLongArray(br);
solve(array, nab[1], nab[2]);
} catch (IOException e) {
e.printStackTrace();
}
}
}
| Main.java:12: error: class TaskB is public, should be declared in a file named TaskB.java
public class TaskB {
^
1 error
|
s601084253 | p03776 | C++ | #include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_map>
#include <map>
using namespace std;
#define ull unsigned long long
ull pow(ull a, ull e){
ull tmp = 1;
while(e > 0){
if( e & 1ll){
tmp = tmp * a;
}
a = a * a;
e >>= 1;
}
return tmp;
}
class Conbination
{
public:
int size;
vector<vector<long long> > nck;
Conbination(int n);
~Conbination();
void setnCk();
long long fetchnCk(int n, int k);
};
Conbination::Conbination(int n){
this->size = n;
setnCk();
}
Conbination::~Conbination(){}
void Conbination::setnCk(){
vector<long long> start;
start.push_back(1.0);
nck.push_back(start);
for (int i = 0; i <= size; ++i)
{
vector<long long> next;
for (int j = 0; j <= i+1; ++j)
{
next.push_back(0);
}
for (int j = 0; j < i+1; ++j)
{
next[j] += nck[i][j];
next[j+1] += nck[i][j];
}
nck.push_back(next);
}
}
long long Conbination::fetchnCk(int n, int k){
return nck[n][k];
}
class MaximumAverageSets
{
public:
int n;
int a;
int b;
vector<double> v;
map<int, int> hash;
MaximumAverageSets(){
cin >> n >> a >> b;
for (int i = 0; i < n; ++i)
{
double tmp;
cin >> tmp;
v.push_back(tmp);
hash[tmp]++;
}
}
void exec(){
double sum = 0;
sort(v.begin(), v.end(), greater<int>());
for (int i = 0; i < a; ++i)
{
sum += v[i];
}
double ave = sum / (a * 1.0);
printf("%.10f\n", ave);
int cnt = n - hash[v[a-1]] > 0 ? n - hash[v[a-1]] : n;
Conbination c = Conbination(hash[v[a-1]]);
long long ans = 0;
for (int i = 0; i < b; ++i)
{
ans += c.fetchnCk(hash[v[a-1]], cnt + i)
if(v[a] != v[i]) break;
}
cout << ans << endl;
}
};
int main(){
MaximumAverageSets mas = MaximumAverageSets();
mas.exec();
}
| a.cc: In member function 'void MaximumAverageSets::exec()':
a.cc:107:25: error: expected ';' before 'if'
107 | if(v[a] != v[i]) break;
| ^~
|
s914040145 | p03776 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
ll arr[60];
ll memo[60][60] = {};
// a C b
ll combi(ll a,ll b){
if(!memo[0][0]){
for(int i = 0; i < 60; i++){
for(int j = 0; j < 60; j++){
if(i == 0 || j == 0){
memo[i][j] = 1;
}else{
memo[i][j] = memo[i-1][j] + memo[i][j-1];
}
}
}
}
return memo[a-b][b];
}
int main(void){
// Here your code !
int n,a,b;
map<ll,ll> number;
cin >> n >> a >> b;
for(int i = 0; i < n; i++){
cin >> arr[i];
number[arr[i]]++;
}
sort(arr,arr+n);
double Max = 0;
for(int i = a; i <= b; i++){
ll total = 0;
for(int j = n - 1; j >= n-i; j--){
total += arr[j];
}
Max = max((double)total/i,Max);
}
printf("%.7lf\n",Max);
ll res = 0;
for(int i = a; i <= b; i++){
ll tmp = 0,total = 0;
for(int k = n-i; k < n; k++){
if(arr[n-i] == arr[k]){
tmp++;
}
total += arr[k];
}
if(fabsl((double)total/i - Max ) < 0.0000001)
res += combi(max(number[arr[n-1-i]] ,tmp), min(number[arr[n-1-i]] ,tmp));
}
cout << res << endl;
}
| a.cc: In function 'int main()':
a.cc:76:12: error: 'fabsl' was not declared in this scope
76 | if(fabsl((double)total/i - Max ) < 0.0000001)
| ^~~~~
|
s338472088 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
int n,a,b,v[51];
int C[51][51];
void comb_table(int N){
for(int i=0;i<=n;i++){
for(int j=0;j<=i;j++){
if(j==0 || j==i){
C[i][j]=1LL;
}else{
C[i][j]=(C[i-1][j-1]+C[i-1][j]);
}
}
}
}
signed main(){
cin>>n>>a>>b;
for(int i=0;i<n;i++){
cin>>v[i];
}
sort(v,v+n);
reverse(v,v+n);
comb_table(n);
double temp=0;
for(int i=0;i<a;i++){
temp+=v[i];
}
cout<<fixed<<setprecision(10)<<temp/a<<endl;
int ans=0;
int x=0;
if(v[a-1]==v[0]){
for(int i=0;i<n;i++){
if(v[i]==v[0])
x++;
}
for(int i=a;i<=b;i++){
ans+=C[x][i]
}
cout<<ans<<endl;
return 0;
}
int a_num=0;
for(int i=0;i<n;i++){
if(v[a-1]==v[i])a_num++;
}
int a_num2=0;
for(int i=0;i<a;i++){
if(v[a-1]==v[i])a_num2++;
}
ans=C[a_num][a_num2];
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:44:19: error: expected ';' before '}' token
44 | ans+=C[x][i]
| ^
| ;
45 | }
| ~
|
s064550872 | p03776 | C++ | #include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
int N, A, B;
ll v[55];
// 組み合わせテーブル
ll C[55][55]; // C[n][k] => nCk
void comb_table(int N){
for (int i=0;i<=N;++i) {
for (int j=0;j<=i;++j) {
if (j==0 or j==i) {
C[i][j] = 1;
} else {
C[i][j] = (C[i-1][j-1]+C[i-1][j]);
}
}
}
}
int main() {
// 入力
cin >> N >> A >> B;
for (int i=0; i<N; i++) cin >> v[i];
// A<=x<=Bの範囲においての価値の平均は、vを降順にソートした後に前からA個選んだ時が最大
sort(v, v+N);
reverse(v, v+N);
ll sum = 0;
double avg;
for (int i=0; i<A; i++) sum += v[i];
avg = (double)sum / A;
// 1行目に平均の最大値を出力
printf("%.6f\n", avg);
// 平均が最大となるような品物の選び方の数を求める
comb_table(N); // 組み合わせテーブルを前処理で求めておく
int anum_equal_cnt, apos_below_cnt;
anum_equal_cnt = apos_below_cnt = 0;
for (int i=0; i<N; i++) {
if (v[i] == v[A-1]) {
anum_equal_cnt++;
if (i < A) {
apos_below_cnt++;
}
}
}
ll cnt = 0;
if (apos_below_cnt == A) {
for (; apos_below_cnt<=B; apos_below_cnt++) {
cnt += C[anum_equal_cnt][apos_below_cnt];
}
} else {
cnt += C[anum_equal_cnt][apos_below_cnt];
}
// 2行目に平均が最大となるような品物の選び方の数を出力
cout << cnt << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:28:3: error: 'sort' was not declared in this scope; did you mean 'short'?
28 | sort(v, v+N);
| ^~~~
| short
a.cc:29:3: error: 'reverse' was not declared in this scope
29 | reverse(v, v+N);
| ^~~~~~~
|
s859546680 | p03776 | C++ | #include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n, a, b;
vector<ll> v;
ll comb(ll n, ll m){
ll ret = 1;
for(ll i=1;i<=m;i++) ret = ret * (n-m+i) / i;
return ret;
}
int main(void){
cin >> n >> a >> b;
for(int i=0;i<n;i++) {ll tmp; cin >> tmp; v.push_back(-tmp);}
sort(v.begin(), v.end());
ll thesum = 0;
for(int i=0;i<a;i++) thesum += (-v[i]);
printf("%.7f\n",((double)(thesum)) / a);
ll ans = 0;
if (v[0]==v[a-1]){
int i;
for(i=a-1;i<n;i++) if (v[0] != v[i]) break;
int m = i;
for(int i=a;i<=min(m,b);i++) ans += comb(m,i);
}else{
int mi, ma;
for(mi=0;mi<n;mi++) if (v[mi]==v[a-1]) break;
for(ma=a-1;ma<n;ma++) if (v[ma]!=v[a-1]) break;
int m = ma - mi;
ans += comb(m, a-mi);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:26:21: error: no matching function for call to 'min(int&, long long int&)'
26 | for(int i=a;i<=min(m,b);i++) ans += comb(m,i);
| ~~~^~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:26:21: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
26 | for(int i=a;i<=min(m,b);i++) ans += comb(m,i);
| ~~~^~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:26:21: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
26 | for(int i=a;i<=min(m,b);i++) ans += comb(m,i);
| ~~~^~~~~
|
s435939808 | p03776 | C++ | #include <iostream>
using namespace std;;
using ll=long long;
// combination table
ll C[51][51]; //C[n][k] -> nCk
void comb_table(int N){
for(int i=0;i<=N;++i){
for(int j=0; j<=i; ++j){
if(j==0 or j==i){
C[i][j]=1LL;
}else{
C[i][j]=(C[i-1][j-1]+C[i-1][j]);
}
}
}
}
int main(){
// input
int N, A, B;
cin >> N >> A >> B;
const int NMAX=50;
ll v[NMAX];
for(int i=0; i<N; ++i){
cin >> v[i];
}
comb_table(N);
sort(v, v+N);
reverse(v,v+N);
double max_average=0.0;
for(int i=0; i<A; i++){
max_average+=v[i];
}
max_average/=A;
int a_th_val_num=0, a_th_val_pos=0;
for(int i=0; i<N; i++){
if(v[i]==v[A-1]){
a_th_val_num++;
if(i<A){
a_th_val_pos++;
}
}
}
ll cnt=0LL;
if(a_th_val_pos==A){
for(a_th_val_pos=A; a_th_val_pos<=B; ++a_th_val_pos){
cnt+=C[a_th_val_num][a_th_val_pos];
}
}else{
cnt+=C[a_th_val_num][a_th_val_pos];
}
cout.precision(20);
cout << fixed << max_average << endl;
cout << cnt << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:33:5: error: 'sort' was not declared in this scope; did you mean 'short'?
33 | sort(v, v+N);
| ^~~~
| short
a.cc:34:5: error: 'reverse' was not declared in this scope
34 | reverse(v,v+N);
| ^~~~~~~
|
s581286457 | p03776 | C++ | #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;
ll comb[51][51];
void com(int n){
rep(i,n+1){
rep(j,i+1){
if(j==0||j==i){
comb[i][j]=1LL;
}
else comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
}
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,a,b;cin>>n>>a>>b;
vector<ll> v;
com(n);
rep(i,n){
ll t;cin>>t;
v.push_back(t);
}
sort(v.begin(),v.end(),greater<ll>());
double sum=0.0;
rep(i,a)sum+=v[i];
sum/=a;
int x=0,y=0;
rep(i,n){
if(v[i]==v[a-1]){
x++;
if(i<a)y++;
}
}
ll ret=0LL;
if(v[0]==v[a-1]){
nrep(i,a,b+1){
ret+=comb[x][i];
}
}
else{
ret+=comb[x][y];
}
prinf("%.7f\n%lld\n",sum,ret);
return 0;
} | a.cc: In function 'int main()':
a.cc:70:1: error: 'prinf' was not declared in this scope; did you mean 'printf'?
70 | prinf("%.7f\n%lld\n",sum,ret);
| ^~~~~
| printf
|
s828081186 | p03776 | C++ | #include <iostream>
using namespace std;
using ll=long long;
using R=double;
// Combination Table
ll C[51][51]; // C[n][k] -> nCk
void comb_table(int N){
for(int i=0;i<=N;++i){
for(int j=0;j<=i;++j){
if(j==0 or j==i){
C[i][j]=1LL;
}else{
C[i][j]=(C[i-1][j-1]+C[i-1][j]);
}
}
}
}
int main(void){
int N,A,B;
cin >> N >> A >> B;
const int NMAX=50;
ll v[NMAX];
for(int i=0;i<N;++i){
cin >> v[i];
}
comb_table(N);
sort(v,v+N);
reverse(v,v+N);
R max_average=0.0;
for(int i=0;i<A;++i){
max_average+=v[i];
}
max_average/=A;
int a_th_val_num=0,a_th_val_pos=0;
for(int i=0;i<N;++i){
if(v[i]==v[A-1]){
a_th_val_num++;
if(i<A){
a_th_val_pos++;
}
}
}
ll cnt=0LL;
if(a_th_val_pos==A){
for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
cnt+=C[a_th_val_num][a_th_val_pos];
}
}else{
cnt+=C[a_th_val_num][a_th_val_pos];
}
cout.precision(20);
cout << fixed << max_average << endl;
cout << cnt << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:33:1: error: 'sort' was not declared in this scope; did you mean 'short'?
33 | sort(v,v+N);
| ^~~~
| short
a.cc:34:1: error: 'reverse' was not declared in this scope
34 | reverse(v,v+N);
| ^~~~~~~
|
s409076079 | p03776 | C | #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<climits> //INT_MIN/MAX
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0,0,1,-1,1,1,-1,-1 };
int dy[8] = { 1,-1,0,0,1,-1,1,-1 };
/* ----- xtimex Problem: ABC 0 ABCD / Link: ----- */
/* ------蝠城。---
-----問題ここまで----- */
/* -----解説等-----
----解説ここまで---- */
ll N, A, B;
ll v[60];
ll ans = 0;
ll comb[100][100];
double ave = 0;
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> N >> A >> B;
FOR(i, 0, N) {
cin >> v[i];
}
for (int i = 0; i <= 60; i++) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i)
comb[i][j] = 1;
else
comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
}
}
sort(v, v + N);
reverse(v, v + N);
if (v[0] != v[A - 1]) {
int cnt = 0, ne = 0;
FOR(i, 0, N) {
if (v[A - 1] == v[i]) {
cnt++;
if (i < A) {
ne++;
}
}
if (i < A)ave += v[i];
}
//debug(cnt);
ave /= A;
ans = comb[cnt][ne];
}
else if (v[0] == v[A - 1]) {
int cnt = 0;
FOR(i, 0, N) {
if (v[0] == v[i])cnt++;
}
ave = v[0];
FOR(i, A, B + 1) {
if (v[0] == v[i - 1]) {
ans += comb[cnt][i - 1];
}
}
}
printf("%.10f\n", ave);
cout << ans << endl;
return 0;
}
| main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s840936158 | p03776 | C++ | #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int main(){
// freopen("in.txt","r",stdin);
int N,A,B;
long long v[51];
cin >> N >> A >> B;
for (int i = 0; i < N; ++i)
{
scanf("%lld",&v[i]);
}
sort(v,v+N,greater<int>());
bool flag = true;
long long SUM = v[0];
for (int i = 1; i < A; ++i)
{
SUM += v[i];
if((double)SUM/i > v[i]){
flag = false;
}
}
int j;
for (j = A; j < B; ++j)
{
if((double)SUM/j > v[j]){
flag = false;
break;
}else{
SUM += v[j];
}
}
int count = 1;
int k = j-1;
while(k>0&&v[k]==v[k-1]){
count++;k--;
}
k = j-1;
while(k<B&&v[k]==v[k+1]){
count++;k++;
}
long long ans;
if(flag) {
int ta = A;long long tn = 1;
while(ta>0){
tn *= ta;
ta--;
}
ans = pow(2,count)-tn;
}
else ans = count;
cout <<SUM <<":" << j<< endl;
printf("%f\n",(double)SUM/j);
printf("%lld\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:22:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
22 | sort(v,v+N,greater<int>());
| ^~~~
| sqrt
|
s311477574 | p03776 | C++ |
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll fun(int x)
{
ll ans=1;
for(int i=1;i<=x;i++)
ans*=i;
return ans;
}
ll fun1(int x,int y)
{
ll ans=1;
for(int i=x;y--;i--)
ans*=i;
return ans;
}
ll s[100];
int main()
{
// cout<<fun1(10,4)+fun1(10,5)<<endl;
ll n;
while(cin>>n)
{
ll a,b;
cin>>a>>b;
for(int i=0;i<n;i++)
cin>>s[i];
sort(s,s+n);
int maxn=s[n-1];
int ans=1;
ll sum=0;
for(int i=n-1;i>n-a-1;i--)
{
sum+=s[i];
}
cout<<sum/(double)a<<endl;
printf("%.6lf",sum/(double)a);
cout<<endl;
int len=n-(lower_bound(s,s+n,s[n-a])-s);
int len1=n-(upper_bound(s,s+n,s[n-a])-s);
int ttt=len-len1;
int biaoji=n-(lower_bound(s,s+n,s[n-1])-s);
if(biaoji<a)
{
printf("%.6lf\n",fun1(ttt,a-len1)/fun(a-len1));
cout<<fun1(ttt,a-len1)/fun(a-len1)<<endl;
}
else if(biaoji==a) {printf("%.6lf\n",s[n-1]); cout<<1<<endl;}
else if(biaoji>a&&biaoji<b)
{
ll ss=0;
for(int i=a;i<=biaoji;i++)
ss+=fun1(biaoji,i)/fun(i);
printf("%.6lf\n",s[n-1])
cout<<ss<<endl;
}
else if(biaoji>=b)
{
ll ss=0;
for(int i=a;i<=b;i++)
ss+=fun1(biaoji,i)/fun(i);
printf("%.6lf\n",s[n-1])
cout<<ss<<endl;
}
}
}
| a.cc: In function 'int main()':
a.cc:74:29: error: expected ';' before 'cout'
74 | printf("%.6lf\n",s[n-1])
| ^
| ;
75 | cout<<ss<<endl;
| ~~~~
a.cc:82:29: error: expected ';' before 'cout'
82 | printf("%.6lf\n",s[n-1])
| ^
| ;
83 | cout<<ss<<endl;
| ~~~~
|
s207425747 | p03776 | C++ | #include <stdio.h>
#include <math.h>
int main(void){
int N, A, B, i, j, k, x = 1, y = 0;
scanf("%d %d %d", &N, &A, &B);
double v[N], S = 0, max_v;
for(i = 0; i < N; i++){
scanf("%lf", &v[i]);
}
for(i = 0; i < N; i++){
max_v = v[i];
for(j = i; j < N; j++){
if(max_v < v[j]){
max_v = v[j];
k = j;
}
}
v[k] = v[i];
v[i] = max_v;
}
for(i = 0; i < A; i++){
S += v[i];
}
printf("%lf\n", S/A);
i = 0;
while(v[A-1]==v[A+i]){
printf("i%d\n", i);
i++;
}
if(S/A == v[A-1]){
k = 0;
for(j = 0; j < B-A; j++)
for(k = 1; k <= A+j; k++){
x *= (A+i-k-1);
}
for(k = 1; k <= A+j; k++){
x /= k;
}
y += x;
}
}else{
printf("%d\n", i+1);
}
scanf("%d", &N);
return 0;
} | a.cc:46:10: error: expected unqualified-id before 'else'
46 | }else{
| ^~~~
a.cc:49:14: error: expected constructor, destructor, or type conversion before '(' token
49 | scanf("%d", &N);
| ^
a.cc:51:9: error: expected unqualified-id before 'return'
51 | return 0;
| ^~~~~~
a.cc:52:1: error: expected declaration before '}' token
52 | }
| ^
|
s435486410 | p03776 | C++ | #include<cstdio>
#include<vector>
#define intq vector<double>
#define intqq vector<int>
#define FOR(i, a, b) for((i)=(a);(i)<(b);(i)++)
#define N (1e+15)
using namespace std;
double fac(double n) {
double r = 1;
double i;
for(i=0;i<n;r *= ++i) {
}
return r;
}
double com(double n, int k) {
double i;
double c;
c = 1;
for(i=0;i<k;i++) {
c *= n - i;
}
for(i=0;i<k;i++) {
c /= i + 1;
}
return c;
}
int main(void) {
int n;
intq v;
int a, b;
scanf("%d %d %d", &n, &a, &b);
int i;
FOR(i, 0, n) {
double c;
scanf("%lf", &c);
v.push_back(c);
}
sort(v.begin(), v.end());
double s = 0.0;
double av;
int c, d;
c = 1;
d = 1;
double p;
intqq t;
for(i=n-1;i-n+a+1;i--) {
s += v[i];
if(n-1-i){
double q;
q = v[i];
if(p == q) {
c++;
d++;
} else {
if(c-1){
c = 1;
d = 1;
t.push_back(c);
}
}
}
printf("c = %d, d = %d\n", c, d);
p = v[i];
}
double r;
r = s / a;
int j;
for(j=i++;v[j] == v[i];j--) {
c++;
}
t.push_back(c);
int u;
u = t.size();
double w = 1;
for(i=0;i<u-1;i++) {
w *= fac(t[i]);
}
double x = 0;
for(j=0;j<b-a+1;j++){
x += com(t[i], d + j);
}
w += x;
printf("%lf\n%lf\n", r, w);
return 0;
} | a.cc: In function 'int main()':
a.cc:44:3: error: 'sort' was not declared in this scope; did you mean 'short'?
44 | sort(v.begin(), v.end());
| ^~~~
| short
|
s826644087 | p03776 | C++ | #include <iostream>
#include <vector>
using ll = long long;
using namespace std;
ll nChoosek(ll n, ll k )
{
if (k > n) return 0;
if (k * 2 > n) k = n-k;
if (k == 0) return 1;
int result = n;
for( int i = 2; i <= k; ++i ) {
result *= (n-i+1);
result /= i;
}
return result;
}
int main()
{
int N, A, B;
vector<ll> v(60);
cin >> N >> A >> B;
for (int i = 0; i < N; i++) {
cin >> v[i];
}
sort(v.begin(), v.end(), greater<ll>());
long double a1 = 0;
for (int i = 0; i < A; i++) {
a1 += v[i];
}
cout << a1 / (long double)A << endl;
ll m = v[A - 1];
int i_min, i_max;
for (int i = 0; i < A; i++) {
if (v[i] == m) {
i_min = i;
break;
}
}
for (int i = A; i < B; i++) {
if (i == B - 1) {
i_max = i;
break;
}
if (v[i] != m) {
i_max = i - 1;
break;
}
}
ll num = i_max - i_min + 1;
ll ans = 0;
for (ll i = A - i_min + 1; i <= num; i++) {
ans += nChoosek(num, i);
}
cout << i_min << ' ' << i_max << ' ' << num << endl;
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:3: error: 'sort' was not declared in this scope; did you mean 'short'?
33 | sort(v.begin(), v.end(), greater<ll>());
| ^~~~
| short
|
s557773356 | p03776 | C++ | using namespace std;
int a,b,n,i,j,k,c[51],d[51],e[51];
float avg;
long long int cnt;
long long int fac(int n) {
int i;
long long int c = 1;
for (i = 1;i <= n;i++) {
c *= i;
}
return c;
}
int main() {
scanf("%d%d%d",&n,&a,&b);
for (i = 1;i <= n;i++) {
scanf("%d",&c[i]);
}
sort(c+1,c+n+1);
reverse(c+1,c+n+1);
k = 0;
for (i = 1;i <= a;i++) {
k = k + c[i];
}
avg = k / a;
printf("%0.6f\n",avg);
for (i = 1;i <= a;i++) {
for (j = 1;j <= n;j++) {
if (c[i] == c[j]) {
d[i] = d[i] + 1;
}
}
}
for (i = 1;i <= a;i++) {
for (j = 1;j <= a;j++) {
if (c[i] == c[j]) {
e[i] = e[i] + 1;
}
}
}
if (c[a] == c[1]) {for (i = e[a];i <= b - a + e[a];i++) {
cnt += fac(d[a]) / (fac(i) * fac(d[a]-i));
}
}
else {
cnt += fac(d[a]) / (fac(e[a]) * fac(d[a]-e[a]));
}
printf("%lld\n",cnt);
} | a.cc: In function 'int main()':
a.cc:17:9: error: 'scanf' was not declared in this scope
17 | scanf("%d%d%d",&n,&a,&b);
| ^~~~~
a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'short'?
21 | sort(c+1,c+n+1);
| ^~~~
| short
a.cc:22:5: error: 'reverse' was not declared in this scope
22 | reverse(c+1,c+n+1);
| ^~~~~~~
a.cc:28:5: error: 'printf' was not declared in this scope
28 | printf("%0.6f\n",avg);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | using namespace std;
|
s420561705 | p03776 | C++ | #include <stdio.h>
#include <math.h>
int main(void){
int N, A, B, i, j, k, x = 1, y = 0;
scanf("%d %d %d", &N, &A, &B);
double v[N], S = 0, max_v;
for(i = 0; i < N; i++){
scanf("%lf", &v[i]);
}
for(i = 0; i < N; i++){
max_v = v[i];
for(j = i; j < N; j++){
if(max_v < v[j]){
max_v = v[j];
k = j;
}
}
v[k] = v[i];
v[i] = max_v;
}
for(i = 0; i < A; i++){
S += v[i];
}
printf("%lf\n", S/A);
i = 0;
while(v[A-1]==v[A+i]){
printf("i%d\n", i);
i++;
}
if(S/A == v[A-1]{
k = 0;
for(j = 0; j < B-A; j++)
for(k = 1, k <= A+j; k++){
x *= (A+i-k-1);
}
for(k = 1, k <= A+j; k++){
x /= k;
}
y += x;
}
}else{
printf("%d\n", i+1);
}
scanf("%d", &N);
return 0;
} | a.cc: In function 'int main()':
a.cc:35:25: error: expected ')' before '{' token
35 | if(S/A == v[A-1]{
| ~ ^
| )
a.cc:46:9: error: expected primary-expression before '}' token
46 | }else{
| ^
a.cc: At global scope:
a.cc:46:10: error: expected unqualified-id before 'else'
46 | }else{
| ^~~~
a.cc:49:14: error: expected constructor, destructor, or type conversion before '(' token
49 | scanf("%d", &N);
| ^
a.cc:51:9: error: expected unqualified-id before 'return'
51 | return 0;
| ^~~~~~
a.cc:52:1: error: expected declaration before '}' token
52 | }
| ^
|
s517389834 | p03776 | C++ | #include<iostream>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
ll kaizyou(int num){
ll result=1;
while(num > 0){
result*=num;
num--;
}
return result;
}
int main(){
int N,A,B;
cin>>N>>A>>B;
vector<ll> v;
REP(i,N){
ll x;
cin>>x;
v.push_back(x);
}
sort(v.begin(),v.end(),greater<ll>());
long double mean = 0;
REP(i,A){
mean += v[i];
}
mean = mean/A;
cout<<mean<<endl;
int before = 0;
REP(i,N){
if(v[i]==v[A-1]){
before = i;
break;
}
};
int after = 0;
REP(i,N){
if(v[N-1-i]==v[A-1]){
after = N-1-i;
break;
}
};
ll sum = 0;
if(before==0){
for (int i = A; i <= B ; ++i)
{
if(i<=after+1){
sum += kaizyou(after+1)/kaizyou(i)/kaizyou(after-i+1);
}
}
}else{
sum = kaizyou(after-before+1)/kaizyou(A-before)/kaizyou(after-A+1);
}
cout<<sum<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:30:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
30 | sort(v.begin(),v.end(),greater<ll>());
| ^~~~
| sqrt
|
s041486406 | p03776 | C++ | #include<bits/stdc++.h>
using namespace std;
#define ULL unsigned long long
ULL n,m;
ULL a,b;
ULL sum1,sum2;
ULL num[100];
bool cmd(ULL x,ULL y)
{
return x>y;
}
map<ULL,ULL>q;
ULL C(ULL n,ULL m)
{
if(n<m) return 0;
ULL ans=1;
for(int i=0;i<m;i++) ans=ans*(ULL)(n-i)/(ULL)(i+1);
return ans;
}
int main()
{
cin>>n>>a>>b;
for(int i=1;i<=n;i++)
{
cin>>num[i];
q[num[i]]++;
}
sort(num+1,num+1+n,cmd);
for(int i=1;i<=a;i++)
{
sum1+=num[i];
}
for(int i=1;i<=b;i++)
{
sum2+=num[i];
}
printf("%.10f\n",max(((double)sum1*1.0/a*1.0,(double)sum2*1.0/b*1.0));
if(sum1*1.0/a*1.0>=sum2*1.0/b*1.0)
{
ULL ans=1;
for(map<ULL,ULL>::reverse_iterator it=q.rbegin();it!=q.rend();it++)
{
ULL x=it->second;
if(a>=x)
{
a-=x;
}
else
{
ans*=C(x,a);
break;
}
}
cout<<ans<<endl;
}
else
{
ULL ans=1;
for(map<ULL,ULL>::reverse_iterator it=q.rbegin();it!=q.rend();it++)
{
ULL x=it->second;
if(b>=x)
{
b-=x;
}
else
{
ans*=C(x,b);
break;
}
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:25: error: no matching function for call to 'max(double)'
37 | printf("%.10f\n",max(((double)sum1*1.0/a*1.0,(double)sum2*1.0/b*1.0));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: template argument deduction/substitution failed:
a.cc:37:25: note: mismatched types 'std::initializer_list<_Tp>' and 'double'
37 | printf("%.10f\n",max(((double)sum1*1.0/a*1.0,(double)sum2*1.0/b*1.0));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 1 provided
|
s307303741 | p03776 | C++ | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
int compare (const void * a, const void * b)
{
return( *(long long *)b - *(long long *)a);
}
int main(){
int N;
int A;
int B;
long long v[50];
int i;
long double average=0;
int ways=1;
scanf("%d %d %d",&N, &A, &B);
for(i=0;i<N;i++) scanf("%lld",&v[i]);
qsort (v, N, sizeof(long long), compare);
for(i=0;i<A;i++) average+=v[A-1-i];
average=average/A;
for(i=A;i<B+1;i++) if(v[i]==v[A-1]) ways++;
printf("%Lf\n%d\n",average,ways);
return 0;
}
b | a.cc:31:1: error: extended character is not valid in an identifier
31 | b
| ^
a.cc:31:1: error: '\U000000a0b' does not name a type
31 | b
| ^~
|
s995476281 | p03776 | C++ | #include "bits/stdc++.h"
#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9
const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
void make_comb(vvl &comb) {
REP(i, comb.size())comb[i][0] = 1;
REP(i, comb.size()-1) {
REP(j, comb[0].size()-1) {
comb[i + 1][j + 1] = comb[i][j] + comb[i][j + 1];
}
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
vvl comb(55, vl(55, 0));
make_comb(comb);
int n, a, b;
cin >> n >> a >> b;
vl v(n);
REP(i, n)cin >> v[i];
sort(ALL(v), greater<ll>());
ll cnt = 0;
long double ans = -1;
FOR(i, a, b + 1) {
ll sum = 0;
REP(j, i)sum += v[j];
int cntal = 0, cntin = 0;
REP(j, n)if (v[j] == v[i - 1])cntal++;
REP(j, i)if (v[j] == v[i - 1])cntin++;
ll p = comb[cntal][cntin];
if ((long double)sum / i + EPS> ans) {
if (abs(long double(sum) / i - ans) < EPS)cnt += p;
else cnt = p;
ans = long double(sum) / i;
}
}
cout << fixed << setprecision(12) << ans << endl;
cout << cnt << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:60:33: error: expected primary-expression before 'long'
60 | if (abs(long double(sum) / i - ans) < EPS)cnt += p;
| ^~~~
a.cc:62:31: error: expected primary-expression before 'long'
62 | ans = long double(sum) / i;
| ^~~~
|
s665267036 | p03776 | C++ | #include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
if (s) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = std::end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = std::end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len) {
dest.setstate(std::ios_base::badbit);
}
}
return dest;
}
typedef __int128 LL;
typedef std::pair<int, int> P;
int N, A, B;
LL v[51];
std::map<LL, LL>tmp;
double avg_ans;
LL how_ans;
LL nPm(LL n, LL m) {
if (m <= 1)
return n;
return (n - m + 1) * nPm(n, m - 1);
}
LL nCm(LL n, LL m) {
return nPm(n, m) / nPm(m, m);
}
int main()
{
in >> N >> A >> B;
rep(i, N) { in >> v[i]; }
std::sort(v, v + N, std::greater<LL>());
rep(i, N)
{
++tmp[v[i]];
}
for (LL num = A; num <= B; ++num)
{
LL sum = 0;
std::map<LL, LL>list;
for (int i = 0; i < num; ++i)
{
sum += v[i];
++list[v[i]];
}
if (avg_ans < (double)sum / (double)num)
{
avg_ans = (double)sum / (double)num;
how_ans = 1;
// tmp[list[i].first] C list[i].second
for (auto x : list)
{
how_ans *= nCm(tmp[x.first], x.second);
}
}
else if (avg_ans == (double)sum / (double)num)
{
LL res = 1;
// tmp[list[i].first] C list[i].second
for (auto x : list)
{
res *= nCm(tmp[x.first], x.second);
}
how_ans += res;
}
}
out << std::fixed << std::setprecision(10);
out << avg_ans << std::endl << how_ans << std::endl;
//for (int i = 1; i <= 50; ++i) { out << nCm(50, i) << std::endl; }
return 0;
} | a.cc: In function 'int main()':
a.cc:66:24: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'LL' {aka '__int128'})
66 | rep(i, N) { in >> v[i]; }
| ^~ ~~~~
| |
| LL {aka __int128}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'LL' {aka '__int128'}
66 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: invalid conversion from 'LL' {aka '__int128'} to 'void*' [-fpermissive]
66 | rep(i, N) { in >> v[i]; }
| ~~~^
| |
| LL {aka __int128}
a.cc:66:30: error: cannot bind rvalue '(void*)((long int)v[i])' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:66:30: error: invalid conversion from 'LL' {aka '__int128'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
66 | rep(i, N) { in >> v[i]; }
| ~~~^
| |
| LL {aka __int128}
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: co |
s839528261 | p03776 | C++ | #include "bits/stdc++.h"
#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9
const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
void make_comb(vvl &comb) {
REP(i, comb.size())comb[i][0] = 1;
REP(i, comb.size()-1) {
REP(j, comb[0].size()-1) {
comb[i + 1][j + 1] = comb[i][j] + comb[i][j + 1];
}
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
vvl comb(55, vl(55, 0));
make_comb(comb);
int n, a, b;
cin >> n >> a >> b;
vl v(n);
REP(i, n)cin >> v[i];
sort(ALL(v), greater<ll>());
ll cnt = 0;
long double ans = -1;
FOR(i, a, b + 1) {
ll sum = 0;
REP(j, i)sum += v[j];
int cntal = 0, cntin = 0;
REP(j, n)if (v[j] == v[i - 1])cntal++;
REP(j, i)if (v[j] == v[i - 1])cntin++;
ll p = comb[cntal][cntin];
if ((long double)sum / i + EPS> ans) {
if (abs(long double(sum) / i - ans) < EPS)cnt += p;
else cnt = p;
ans = long double(sum) / i;
}
}
cout << fixed << setprecision(12) << ans << endl;
cout << cnt << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:60:33: error: expected primary-expression before 'long'
60 | if (abs(long double(sum) / i - ans) < EPS)cnt += p;
| ^~~~
a.cc:62:31: error: expected primary-expression before 'long'
62 | ans = long double(sum) / i;
| ^~~~
|
s551480799 | p03776 | C++ | #include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef __int128 LL;
typedef std::pair<int, int> P;
int N, A, B;
LL v[51];
std::map<LL, LL>tmp;
double avg_ans;
LL how_ans;
LL nPm(LL n, LL m) {
if (m <= 1)
return n;
return (n - m + 1) * nPm(n, m - 1);
}
LL nCm(LL n, LL m) {
return nPm(n, m) / nPm(m, m);
}
int main()
{
in >> N >> A >> B;
rep(i, N) { in >> v[i]; }
std::sort(v, v + N, std::greater<LL>());
rep(i, N)
{
++tmp[v[i]];
}
for (LL num = A; num <= B; ++num)
{
LL sum = 0;
std::map<LL, LL>list;
for (int i = 0; i < num; ++i)
{
sum += v[i];
++list[v[i]];
}
if (avg_ans < (double)sum / (double)num)
{
avg_ans = (double)sum / (double)num;
how_ans = 1;
// tmp[list[i].first] C list[i].second
for (auto x : list)
{
how_ans *= nCm(tmp[x.first], x.second);
}
}
else if (avg_ans == (double)sum / (double)num)
{
LL res = 1;
// tmp[list[i].first] C list[i].second
for (auto x : list)
{
res *= nCm(tmp[x.first], x.second);
}
how_ans += res;
}
}
out << std::fixed << std::setprecision(10);
out << avg_ans << std::endl << how_ans << std::endl;
//for (int i = 1; i <= 50; ++i) { out << nCm(50, i) << std::endl; }
return 0;
} | a.cc: In function 'int main()':
a.cc:43:24: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'LL' {aka '__int128'})
43 | rep(i, N) { in >> v[i]; }
| ^~ ~~~~
| |
| LL {aka __int128}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:4:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'LL' {aka '__int128'}
43 | rep(i, N) { in >> v[i]; }
| ~~~^
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: invalid conversion from 'LL' {aka '__int128'} to 'void*' [-fpermissive]
43 | rep(i, N) { in >> v[i]; }
| ~~~^
| |
| LL {aka __int128}
a.cc:43:30: error: cannot bind rvalue '(void*)((long int)v[i])' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: invalid conversion from 'LL' {aka '__int128'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
43 | rep(i, N) { in >> v[i]; }
| ~~~^
| |
| LL {aka __int128}
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed:
a.cc:43:30: error: invalid conversion from 'LL' {aka '__int128'} to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios |
s430315071 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = __int128;
using ld = long double;
const ld eps = 1e-6;
ll combi(ll n, ll k) {
assert(k >= 0 && k <= n);
ll res = 1;
for (int i = 1; i <= k; i++) {
res = res * (n - k + i) / i;
}
return res;
}
int main()
{
int N, A, B;
cin >> N >> A >> B;
vector<ll> v(N);
for (int i = 0; i < N; i++) {
cin >> v[i];
}
sort(v.begin(), v.end());
ll sum = 0, cnt = 0, res = 0;
ld mav = 0;
for (int i = 0; i < A - 1; i++) {
sum += v[N - i - 1];
cnt++;
}
for (int i = A - 1; i < B; i++) {
sum += v[N - i - 1];
cnt++;
ld av = (ld)sum / cnt;
if (mav <= av + eps) {
res = 0;
mav = av;
}
if (av >= mav - eps) {
res += combi(count(v.begin(), v.end(), v[N - i - 1]), (upper_bound(v.begin(), v.end(), v[N - i - 1]) - v.begin()) - (N - i - 1));
}
}
cout << fixed << setprecision(7) << mav << endl;
cout << res << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:21: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'})
22 | cin >> v[i];
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:170:7: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:174:7: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:177:7: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:181:7: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:184:7: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:188:7: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:192:7: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:199:7: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:203:7: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:219:7: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:223:7: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:227:7: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'}
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:328:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'void*' [-fpermissive]
328 | operator>>(void*& __p)
| ^~~~~~~~
| |
| __gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type {aka __int128}
/usr/include/c++/14/istream:328:7: error: cannot bind rvalue '(void*)((long int)v.std::vector<__int128>::operator[](((std::vector<__int128>::size_type)i)))' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/istream:122:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
| |
| __gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type {aka __int128}
/usr/include/c++/14/istream:126:7: note: candidate |
s732217164 | p03776 | Java | import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
static InputReader in = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
int n, a, b;
long[] v = new long[100];
HashMap<Long, Integer> m = new HashMap<>();
BigInteger fac(int x){
BigInteger c = new BigInteger("1");
for(int i=1; i<=x; i++) {
c = c.multiply(new BigInteger(""+i));
}
return c;
}
BigInteger ncr(int n, int k){
return fac(n).divide(fac(k)).divide(fac(n-k));
}
void solve(){
n = in.nextInt();
a = in.nextInt();
b = in.nextInt();
for(int i=1; i<=n; i++){ v[i] = in.nextLong();
m.put(v[i], m.getOrDefault(v[i], 0) + 1);
}
Arrays.sort(v, 1, n+1);
long maxsum = 0;
for(int j=1, i = n; j <= a; j++,i--){
maxsum += v[i];
}
if(a == n){
out.printf("%.10f\n%d\n", (double)maxsum/(double)n, 1);
}
else{
double ans = (double)maxsum/a;
BigInteger ways = new BigInteger("0");
if(v[n-a] < v[n-a+1]) ways = new BigInteger("1");
else{
int k = n-a+1;
while(k+1 <= n && v[k+1] == v[k]) k++;
int occ = k - (n-a+1) + 1;
// compute X choose occ
ways = ncr(m.get(v[n-a+1]), occ);
}
out.printf("%.10f\n%s\n", ans, ways);
}
}
public static void main(String[] args){
a m = new a();
m.solve();
out.flush();
out.close();
}
static class InputReader{
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream instream){
reader = new BufferedReader(new InputStreamReader(instream), 1<<15);
tokenizer = null;
}
public String next(){
while(tokenizer == null || !tokenizer.hasMoreTokens()){
try{
tokenizer = new StringTokenizer(reader.readLine());
}catch(Exception e){
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine(){
try{
return reader.readLine();
}catch(Exception e){
throw new RuntimeException(e);
}
}
public int nextInt(){
return Integer.parseInt(next());
}
public long nextLong(){
return Long.parseLong(next());
}
public double nextDouble(){
return Double.parseDouble(next());
}
}
}
| Main.java:75: error: cannot find symbol
a m = new a();
^
symbol: class a
location: class Main
Main.java:75: error: cannot find symbol
a m = new a();
^
symbol: class a
location: class Main
2 errors
|
s152865136 | p03776 | Java | import java.util.*;
import java.io.*;
import java.math.*;
public class a{
static InputReader in = new InputReader(System.in);
static PrintWriter out = new PrintWriter(System.out);
int n, a, b;
long[] v = new long[100];
HashMap<Long, Integer> m = new HashMap<>();
BigInteger fac(int x){
BigInteger c = new BigInteger("1");
for(int i=1; i<=x; i++) {
c = c.multiply(new BigInteger(""+i));
}
return c;
}
BigInteger ncr(int n, int k){
return fac(n).divide(fac(k)).divide(fac(n-k));
}
void solve(){
n = in.nextInt();
a = in.nextInt();
b = in.nextInt();
for(int i=1; i<=n; i++){ v[i] = in.nextLong();
m.put(v[i], m.getOrDefault(v[i], 0) + 1);
}
Arrays.sort(v, 1, n+1);
long maxsum = 0;
for(int j=1, i = n; j <= a; j++,i--){
maxsum += v[i];
}
if(a == n){
out.printf("%.10f\n%d\n", (double)maxsum/(double)n, 1);
}
else{
double ans = (double)maxsum/a;
BigInteger ways = new BigInteger("0");
if(v[n-a] < v[n-a+1]) ways = new BigInteger("1");
else{
int k = n-a+1;
while(k+1 <= n && v[k+1] == v[k]) k++;
int occ = k - (n-a+1) + 1;
// compute X choose occ
ways = ncr(m.get(v[n-a+1]), occ);
}
out.printf("%.10f\n%s\n", ans, ways);
}
}
public static void main(String[] args){
a m = new a();
m.solve();
out.flush();
out.close();
}
static class InputReader{
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream instream){
reader = new BufferedReader(new InputStreamReader(instream), 1<<15);
tokenizer = null;
}
public String next(){
while(tokenizer == null || !tokenizer.hasMoreTokens()){
try{
tokenizer = new StringTokenizer(reader.readLine());
}catch(Exception e){
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine(){
try{
return reader.readLine();
}catch(Exception e){
throw new RuntimeException(e);
}
}
public int nextInt(){
return Integer.parseInt(next());
}
public long nextLong(){
return Long.parseLong(next());
}
public double nextDouble(){
return Double.parseDouble(next());
}
}
}
| Main.java:4: error: class a is public, should be declared in a file named a.java
public class a{
^
1 error
|
s270618831 | p03776 | C++ |
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#define in std::cin
#define out std::cout
template<typename Arithmetic, typename Integral>
std::enable_if_t< std::is_unsigned<Integral>::value, Arithmetic>
ipow(Arithmetic bace, Integral n)
{
//繰り返し二条法
auto res = (Arithmetic)(1);
while (n > 0) {
if (n & 1) res *= bace;
bace *= bace;
n >>= 1;
}
return res;
}
constexpr bool is_prime(uint64_t N)
{
if (N <= 1) {
return false;
}
for (uint64_t i = 2; i <= N/i+1; ++i)
{
if (N%i == 0) {
return false;
}
}
return true;
}
static_assert(is_prime(7365373222715531));
static_assert(false);
template <uint64_t MOD> class mint_base;
//mint_base_base型用の累乗関数
template <uint64_t MOD> constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept;
//mod計算を自動で行う整数テンプレートクラス
template <uint64_t MOD_ = 1000000007>
class mint_base
{
public:
static constexpr auto MOD = MOD_;
static_assert(!(MOD <= 2), "MOD cannot be below 2.");
static_assert(MOD <= (0xFFFFFFFFFFFFFFFF / 2), "MOD is too big");//加算してオーバーフローしない
//static_assert(MOD <= 0xFFFFFFFF, "MOD is too big");//乗算してオーバーフローしない
constexpr mint_base<MOD> operator+(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v += other;
}
constexpr mint_base<MOD> operator-(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v -= other;
}
constexpr mint_base<MOD> operator*(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v *= other;
}
constexpr auto operator/(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v /= other;
}
constexpr mint_base<MOD>& operator+=(const mint_base<MOD> &other) noexcept
{
a += other.a;
if (MOD <= a) { a -= MOD; };
return *this;
}
constexpr mint_base<MOD>& operator-=(const mint_base<MOD> &other) noexcept
{
if (a >= other.a) {
a -= other.a;
}
else {
a = (a + MOD) - other.a;
}
return *this;
}
constexpr mint_base<MOD>& operator*=(const mint_base<MOD> &other) noexcept
{
#if 0
a *= other.a;
a %= MOD;
#else
//MOD <= (MAXUINT64 / 2)条件下
uint64_t b = other.a, v = 0;
while (b > 0) {
if (b & 1) {
v += a;
if (v >= MOD)v -= MOD;
}
*this+=*this;
b >>= 1;
}
a = v;
#endif
return *this;
}
constexpr std::enable_if_t<is_prime(MOD), mint_base<MOD>&>
operator/=(const mint_base<MOD> &other) noexcept
{
return *this *= ipow(other, MOD - 2);
}
constexpr mint_base<MOD> operator+()const noexcept { return *this; }
constexpr mint_base<MOD> operator-()const noexcept
{
return{ MOD - a, mod_value_tag{} };
}
constexpr mint_base<MOD>& operator++() noexcept
{
if (MOD <= ++a) { a = 0; };
return *this;
}
constexpr mint_base<MOD>& operator--() noexcept
{
if (a <= 0) { a = MOD; };
--a;
return *this;
}
constexpr mint_base<MOD> operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
constexpr mint_base<MOD> operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
//constexpr mint_base<MOD> operator~()const noexcept
//{
// return ipow(*this, e_phi - 1);
//}
constexpr mint_base<MOD>& operator=(const mint_base<MOD> &other) noexcept
{
a = other.a;
return *this;
}
constexpr explicit operator uint64_t()const noexcept
{
return a;
}
constexpr explicit operator unsigned()const noexcept
{
return (unsigned)a;
}
static constexpr uint64_t getmod() noexcept
{
return MOD;
}
constexpr mint_base(uint64_t a_) noexcept :a(a_ % MOD) {}
constexpr mint_base()noexcept : a(0) {}
struct mod_value_tag {};
constexpr mint_base(uint64_t a_, mod_value_tag) :a(a_) {}
private:
//static constexpr uint64_t get_e_phi()noexcept {
// //オイラー値の導出
// uint64_t temp = MOD;
// uint64_t m_ = MOD;
// for (uint64_t i = 2; i <= m_/i+1; ++i)
// {
// if (m_ % i == 0)
// {
// temp = temp / i * (i - 1);
// for (; m_ % i == 0; m_ /= i);
// }
// }
// if (m_ == 1)temp = temp / m_ * (m_ - 1);
// return temp;
//}
//static constexpr uint64_t e_phi = get_e_phi();//オイラー値
uint64_t a;
};
//mint_base型用の累乗関数
template<uint64_t MOD>constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept
{
mint_base<MOD> res = 1;
while (n > 0)
{
if (n & 1)res *= x;
x *= x;
n >>= 1;
}
return res;
}
//mint_baseの階乗計算
//O(x)時間が必要のため、fact_set関数を推奨する。
template<uint64_t MOD>constexpr mint_base<MOD> fact(mint_base<MOD> x)noexcept
{
mint_base<MOD> res(1);
for (uint64_t i = 1; i <= (uint64_t)x; ++i)
{
res *= i;
}
return res;
}
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(x)時間が必要
template<uint64_t MOD>std::vector<mint_base<MOD>> fact_set(mint_base<MOD> x = mint_base<MOD>(-1))
{
mint_base<MOD> res(1);
std::vector<mint_base<MOD>> set((uint64_t)(x)+1);
set[0] = 1;
for (uint64_t i = 1; i <= (uint64_t)x; ++i)
{
res *= i;
set[i] = res;
}
return res;
}
//mint_base型のstreamへの出力
template<uint64_t MOD> std::ostream& operator<<(std::ostream& os, mint_base<MOD> i)
{
os << (uint64_t)i;
return os;
}
//mint_base型のstreamからの入力
template<uint64_t MOD> std::istream& operator >> (std::istream& is, mint_base<MOD>& i)
{
uint64_t tmp;
is >> tmp;
i = tmp;
return is;
}
typedef mint_base<7365373222715531> mint;//最大の答えより大きいmod
namespace mint_literal {
constexpr mint operator""_mi(unsigned long long x)noexcept {
return mint(x);
}
}
using namespace mint_literal;
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(N) //O(1)
template<uint64_t X, uint64_t MOD = mint::MOD>
/*constexpr*/ std::array<mint_base<MOD>, X + 1> fact_set_c()
{
mint_base<MOD> res(1);
std::array<mint_base<MOD>, X + 1> set;
set[0] = 1;
for (uint64_t i = 1; i <= X; ++i)
{
res *= i;
set[i] = res;
}
return set;
}
auto fact_v = fact_set_c<51>();
int32_t N;
int32_t MIN, MAX;
int64_t A[100];
int main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in >> N;
in >> MIN >> MAX;
for (size_t i = 0; i < N; i++)
{
in >> A[i];
}
std::sort(A, A + N, std::greater<>{});
double sum = 0;
for (size_t i = 0; i < MIN; ++i)
{
sum += A[i];
}
out << std::fixed << std::setprecision(7) << sum / MIN << endl;
auto range = std::equal_range(A, A + N, A[MIN - 1]);
auto range_lrngth = range.second - range.first;
auto not_free = range.first - A;
mint count = 0;
for (size_t i = MIN; i <= MAX; ++i)
{
auto free = (MIN - not_free) + (i-MIN);
count += fact_v[free] / fact_v[(MIN - not_free)] / fact_v[free - (MIN - not_free)];
}
out << count << endl;
#if 0
using BS_INT = double;
BS_INT beg = 1, end = 10000000000000000 + 1;
for (size_t loop = 0; loop < 10000; loop++)
{
BS_INT mid = (beg + end) / 2;
bool ok = false;
//平均をmidに出来るか
BS_INT cap = 0;
for (size_t i = 0; i < MIN; i++) {
cap += (A[i] - mid);
}
if (cap >= 0) { ok = true; }
else for (size_t i = MIN; i < MAX; i++) {
cap += (A[i] - mid);
if (cap >= 0) { ok = true; break; }
}
if (ok) {
beg = mid;
}
else {
end = mid;
}
}
out << beg << endl;
#endif
return 0;
}
#endif
| a.cc:50:23: error: non-constant condition for static assertion
50 | static_assert(is_prime(7365373222715531));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:50:23: in 'constexpr' expansion of 'is_prime(7365373222715531)'
a.cc:42:9: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit)
42 | for (uint64_t i = 2; i <= N/i+1; ++i)
| ^~~
a.cc:51:15: error: static assertion failed
51 | static_assert(false);
| ^~~~~
a.cc: In instantiation of 'class mint_base<7365373222715531>':
a.cc:252:52: required from here
252 | constexpr mint operator""_mi(unsigned long long x)noexcept {
| ^~~~~~~~
a.cc:121:37: in 'constexpr' expansion of 'is_prime(((long unsigned int)mint_base<7365373222715531>::MOD))'
a.cc:42:9: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit)
42 | for (uint64_t i = 2; i <= N/i+1; ++i)
| ^~~
a.cc:121:44: note: in template argument for type 'bool'
121 | constexpr std::enable_if_t<is_prime(MOD), mint_base<MOD>&>
| ~~~~~~~~^~~~~
a.cc: In instantiation of 'constexpr auto mint_base<MOD>::operator/(const mint_base<MOD>&) const [with long unsigned int MOD_ = 7365373222715531]':
a.cc:307:50: required from here
307 | count += fact_v[free] / fact_v[(MIN - not_free)] / fact_v[free - (MIN - not_free)];
| ^
a.cc:83:26: error: no match for 'operator/=' (operand types are 'mint_base<7365373222715531>' and 'const mint_base<7365373222715531>')
83 | return v /= other;
| ~~^~~~~~~~
|
s935702859 | p03776 | C++ |
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#define in std::cin
#define out std::cout
template<typename Arithmetic, typename Integral>
std::enable_if_t< std::is_unsigned<Integral>::value, Arithmetic>
ipow(Arithmetic bace, Integral n)
{
//繰り返し二条法
auto res = (Arithmetic)(1);
while (n > 0) {
if (n & 1) res *= bace;
bace *= bace;
n >>= 1;
}
return res;
}
constexpr bool is_prime(uint64_t N)
{
if (N <= 1) {
return false;
}
for (uint64_t i = 2; i <= N/i+1; ++i)
{
if (N%i == 0) {
return false;
}
}
return true;
}
static_assert(is_prime(7365373222715531));
static_assert(false);
template <uint64_t MOD> class mint_base;
//mint_base_base型用の累乗関数
template <uint64_t MOD> constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept;
//mod計算を自動で行う整数テンプレートクラス
template <uint64_t MOD_ = 1000000007>
class mint_base
{
public:
static constexpr auto MOD = MOD_;
static_assert(!(MOD <= 2), "MOD cannot be below 2.");
static_assert(MOD <= (0xFFFFFFFFFFFFFFFF / 2), "MOD is too big");//加算してオーバーフローしない
//static_assert(MOD <= 0xFFFFFFFF, "MOD is too big");//乗算してオーバーフローしない
constexpr mint_base<MOD> operator+(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v += other;
}
constexpr mint_base<MOD> operator-(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v -= other;
}
constexpr mint_base<MOD> operator*(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v *= other;
}
constexpr auto operator/(const mint_base<MOD> &other)const noexcept
{
auto v = *this;
return v /= other;
}
constexpr mint_base<MOD>& operator+=(const mint_base<MOD> &other) noexcept
{
a += other.a;
if (MOD <= a) { a -= MOD; };
return *this;
}
constexpr mint_base<MOD>& operator-=(const mint_base<MOD> &other) noexcept
{
if (a >= other.a) {
a -= other.a;
}
else {
a = (a + MOD) - other.a;
}
return *this;
}
constexpr mint_base<MOD>& operator*=(const mint_base<MOD> &other) noexcept
{
#if 0
a *= other.a;
a %= MOD;
#else
//MOD <= (MAXUINT64 / 2)条件下
uint64_t b = other.a, v = 0;
while (b > 0) {
if (b & 1) {
v += a;
if (v >= MOD)v -= MOD;
}
*this+=*this;
b >>= 1;
}
a = v;
#endif
return *this;
}
constexpr std::enable_if_t<is_prime(MOD), mint_base<MOD>&>
operator/=(const mint_base<MOD> &other) noexcept
{
return *this *= ipow(other, MOD - 2);
}
constexpr mint_base<MOD> operator+()const noexcept { return *this; }
constexpr mint_base<MOD> operator-()const noexcept
{
return{ MOD - a, mod_value_tag{} };
}
constexpr mint_base<MOD>& operator++() noexcept
{
if (MOD <= ++a) { a = 0; };
return *this;
}
constexpr mint_base<MOD>& operator--() noexcept
{
if (a <= 0) { a = MOD; };
--a;
return *this;
}
constexpr mint_base<MOD> operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
constexpr mint_base<MOD> operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
//constexpr mint_base<MOD> operator~()const noexcept
//{
// return ipow(*this, e_phi - 1);
//}
constexpr mint_base<MOD>& operator=(const mint_base<MOD> &other) noexcept
{
a = other.a;
return *this;
}
constexpr explicit operator uint64_t()const noexcept
{
return a;
}
constexpr explicit operator unsigned()const noexcept
{
return (unsigned)a;
}
static constexpr uint64_t getmod() noexcept
{
return MOD;
}
constexpr mint_base(uint64_t a_) noexcept :a(a_ % MOD) {}
constexpr mint_base()noexcept : a(0) {}
struct mod_value_tag {};
constexpr mint_base(uint64_t a_, mod_value_tag) :a(a_) {}
private:
//static constexpr uint64_t get_e_phi()noexcept {
// //オイラー値の導出
// uint64_t temp = MOD;
// uint64_t m_ = MOD;
// for (uint64_t i = 2; i <= m_/i+1; ++i)
// {
// if (m_ % i == 0)
// {
// temp = temp / i * (i - 1);
// for (; m_ % i == 0; m_ /= i);
// }
// }
// if (m_ == 1)temp = temp / m_ * (m_ - 1);
// return temp;
//}
//static constexpr uint64_t e_phi = get_e_phi();//オイラー値
uint64_t a;
};
//mint_base型用の累乗関数
template<uint64_t MOD>constexpr mint_base<MOD> m_pow(mint_base<MOD> x, uint64_t n)noexcept
{
mint_base<MOD> res = 1;
while (n > 0)
{
if (n & 1)res *= x;
x *= x;
n >>= 1;
}
return res;
}
//mint_baseの階乗計算
//O(x)時間が必要のため、fact_set関数を推奨する。
template<uint64_t MOD>constexpr mint_base<MOD> fact(mint_base<MOD> x)noexcept
{
mint_base<MOD> res(1);
for (uint64_t i = 1; i <= (uint64_t)x; ++i)
{
res *= i;
}
return res;
}
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(x)時間が必要
template<uint64_t MOD>std::vector<mint_base<MOD>> fact_set(mint_base<MOD> x = mint_base<MOD>(-1))
{
mint_base<MOD> res(1);
std::vector<mint_base<MOD>> set((uint64_t)(x)+1);
set[0] = 1;
for (uint64_t i = 1; i <= (uint64_t)x; ++i)
{
res *= i;
set[i] = res;
}
return res;
}
//mint_base型のstreamへの出力
template<uint64_t MOD> std::ostream& operator<<(std::ostream& os, mint_base<MOD> i)
{
os << (uint64_t)i;
return os;
}
//mint_base型のstreamからの入力
template<uint64_t MOD> std::istream& operator >> (std::istream& is, mint_base<MOD>& i)
{
uint64_t tmp;
is >> tmp;
i = tmp;
return is;
}
typedef mint_base<7365373222715531> mint;//最大の答えより大きいmod
namespace mint_literal {
constexpr mint operator""_mi(unsigned long long x)noexcept {
return mint(x);
}
}
using namespace mint_literal;
//mint_baseの階乗計算
//0からxまでの階乗を返す
//O(N) //O(1)
template<uint64_t X, uint64_t MOD = mint::MOD>
/*constexpr*/ std::array<mint_base<MOD>, X + 1> fact_set_c()
{
mint_base<MOD> res(1);
std::array<mint_base<MOD>, X + 1> set;
set[0] = 1;
for (uint64_t i = 1; i <= X; ++i)
{
res *= i;
set[i] = res;
}
return set;
}
auto fact_v = fact_set_c<51>();
int32_t N;
int32_t MIN, MAX;
int64_t A[100];
int main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in >> N;
in >> MIN >> MAX;
for (size_t i = 0; i < N; i++)
{
in >> A[i];
}
std::sort(A, A + N, std::greater<>{});
double sum = 0;
for (size_t i = 0; i < MIN; ++i)
{
sum += A[i];
}
out << std::fixed << std::setprecision(7) << sum / MIN << endl;
auto range = std::equal_range(A, A + N, A[MIN - 1]);
auto range_lrngth = range.second - range.first;
auto not_free = range.first - A;
mint count = 0;
for (size_t i = MIN; i <= MAX; ++i)
{
auto free = (MIN - not_free) + (i-MIN);
count += fact_v[free] / fact_v[(MIN - not_free)] / fact_v[free - (MIN - not_free)];
}
out << count << endl;
#if 0
using BS_INT = double;
BS_INT beg = 1, end = 10000000000000000 + 1;
for (size_t loop = 0; loop < 10000; loop++)
{
BS_INT mid = (beg + end) / 2;
bool ok = false;
//平均をmidに出来るか
BS_INT cap = 0;
for (size_t i = 0; i < MIN; i++) {
cap += (A[i] - mid);
}
if (cap >= 0) { ok = true; }
else for (size_t i = MIN; i < MAX; i++) {
cap += (A[i] - mid);
if (cap >= 0) { ok = true; break; }
}
if (ok) {
beg = mid;
}
else {
end = mid;
}
}
out << beg << endl;
#endif
return 0;
}
#endif
| a.cc:50:23: error: non-constant condition for static assertion
50 | static_assert(is_prime(7365373222715531));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:50:23: in 'constexpr' expansion of 'is_prime(7365373222715531)'
a.cc:42:9: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit)
42 | for (uint64_t i = 2; i <= N/i+1; ++i)
| ^~~
a.cc:51:15: error: static assertion failed
51 | static_assert(false);
| ^~~~~
a.cc: In instantiation of 'class mint_base<7365373222715531>':
a.cc:252:52: required from here
252 | constexpr mint operator""_mi(unsigned long long x)noexcept {
| ^~~~~~~~
a.cc:121:37: in 'constexpr' expansion of 'is_prime(((long unsigned int)mint_base<7365373222715531>::MOD))'
a.cc:42:9: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit)
42 | for (uint64_t i = 2; i <= N/i+1; ++i)
| ^~~
a.cc:121:44: note: in template argument for type 'bool'
121 | constexpr std::enable_if_t<is_prime(MOD), mint_base<MOD>&>
| ~~~~~~~~^~~~~
a.cc: In instantiation of 'constexpr auto mint_base<MOD>::operator/(const mint_base<MOD>&) const [with long unsigned int MOD_ = 7365373222715531]':
a.cc:307:50: required from here
307 | count += fact_v[free] / fact_v[(MIN - not_free)] / fact_v[free - (MIN - not_free)];
| ^
a.cc:83:26: error: no match for 'operator/=' (operand types are 'mint_base<7365373222715531>' and 'const mint_base<7365373222715531>')
83 | return v /= other;
| ~~^~~~~~~~
|
s380410186 | p03776 | Java | import java.math.BigDecimal;
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int A = sc.nextInt();
int B = sc.nextInt();
long[] w=new long[N];
for(int i=0;i<N;i++){
w[i]=sc.nextLong();
}
Arrays.sort(w);
long[] v=new long[N];
for(int i=0;i<N;i++){
v[N-1-i]=w[i];
}
long border=v[A-1];
int borderNum=0;
for(int i=A-1;i>=0;i--){
if(v[i]!=border){
break;
}
borderNum++;
}
int p=borderNum;
long result=0;
for(int i=A;i<N;i++){
if(v[i]!=border){
break;
}
borderNum++;
}
if(v[A-1]==v[0]) {
for (int i = A - 1; i < B; i++) {
if (v[i] != border) {
break;
}
result += calcCombination(borderNum,p + i - A + 1);
}
}else{
result += calcCombination(borderNum, p);
}
long sum=0;
for(int i=0;i<A;i++){
sum+=v[i];
}
System.out.println(BigDecimal.valueOf((double)sum/(double)A).toPlainString());
System.out.println(result);
return;
} | Main.java:59: error: reached end of file while parsing
}
^
1 error
|
s216421394 | p03776 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N,A,B;
ll V[1010];
ll ma[51][51];
ll num[51][51];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N>>A>>B;
FOR(i,N) cin>>V[i];
MINUS(ma);
ma[0][0]=0;
num[0][0]=1;
FOR(i,N) {
FOR(x,N) if(num[i][x]>0) {
// take
if(ma[i+1][x+1] < ma[i][x]+V[i]) ma[i+1][x+1] = ma[i][x]+V[i], num[i+1][x+1]=0;
if(ma[i+1][x+1] == ma[i][x]+V[i]) num[i+1][x+1] += num[i][x];
// not take
if(ma[i+1][x] < ma[i][x]) ma[i+1][x] = ma[i][x], num[i+1][x]=0;
if(ma[i+1][x] == ma[i][x]) num[i+1][x] += num[i][x];
}
}
ll p=0,q=1;
ll ret=0;
for(i=A;i<=B;i++) {
if(q*ma[N][i] > p*i) p=ma[N][i], q=i, ret=0;
if(q*ma[N][i] == p*i) ret += num[N][i];
}
_P("%.12lf %lld\n",(double)p/q, hoge);
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
| a.cc: In function 'void solve()':
a.cc:48:41: error: 'hoge' was not declared in this scope
48 | _P("%.12lf %lld\n",(double)p/q, hoge);
| ^~~~
a.cc:6:30: note: in definition of macro '_P'
6 | #define _P(...) (void)printf(__VA_ARGS__)
| ^~~~~~~~~~~
|
s514624471 | p03776 | Java | import java.io.*;
import java.util.*;
public final class max_avg
{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static FastScanner sc=new FastScanner(br);
static PrintWriter out=new PrintWriter(System.out);
static Random rnd=new Random();
static long[][] dp;
static Map<Long,Integer> m1=new HashMap<>();
public static void main(String args[]) throws Exception
{
dp=new long[52][52];dp[0][0]=1;
for(int i=1;i<52;i++)
{
for(int j=0;j<52;j++)
{
dp[i][j]=dp[i-1][j];
if(j>0)
{
dp[i][j]+=dp[i-1][j-1];
}
}
}
int n=sc.nextInt(),a1=sc.nextInt(),b1=sc.nextInt();long[] a=new long[n];double max=-1;
ArrayList<Integer> al=new ArrayList<Integer>();
for(int i=0;i<n;i++)
{
a[i]=sc.nextLong();m1.put(a[i],m1.getOrDefault(a[i],0)+1);
}
Arrays.sort(a);double val1=0,val2=0;
for(int i=n-1;i>=0;i--)
{
val1+=a[i];val2++;
if(val2>=a1 && val2<=b1)
{
double now=val1/val2;
if(now>max)
{
max=now;al.clear();al.add(i);
}
else if(now==max)
{
al.add(i);
}
}
}
long res=0;
for(int i=0;i<al.size();i++)
{
int k=al.get(i);Map<Long,Integer> m2=new HashMap<>();
for(int j=n-1;j>=k;j--)
{
m2.put(a[j],m2.getOrDefault(a[j],0)+1);
}
long curr=1;
for(Map.Entry<Long,Integer> en:m2.entrySet())
{
int x=m1.get(en.getKey()),y=en.getValue();
curr=(curr*dp[x][y]);
}
res=res+curr;
}
out.printf("%.10f \n%d\n",max,res);out.close();
}
}
class FastScanner
{
BufferedReader in;
StringTokenizer st;
public FastScanner(BufferedReader in) {
this.in = in;
}
public String nextToken() throws Exception {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(in.readLine());
}
return st.nextToken();
}
public String next() throws Exception {
return nextToken().toString();
}
public int nextInt() throws Exception {
return Integer.parseInt(nextToken());
}
public long nextLong() throws Exception {
return Long.parseLong(nextToken());
}
public double nextDouble() throws Exception {
return Double.parseDouble(nextToken());
}
} | Main.java:3: error: class max_avg is public, should be declared in a file named max_avg.java
public final class max_avg
^
1 error
|
s594369436 | p03777 | C++ | #include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#define ynmes(a) (a) ? mes("Yes") : mes("No")
#define YNmes(a) (a) ? mes("YES") : mes("NO")
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
signed main() {
string a, b;
cin >> n >> m;
(a == b) ? mes("H") : mes("D");
}
| a.cc: In function 'int main()':
a.cc:76:12: error: 'n' was not declared in this scope
76 | cin >> n >> m;
| ^
a.cc:76:17: error: 'm' was not declared in this scope
76 | cin >> n >> m;
| ^
|
s540742220 | p03777 | C++ | #include <bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------
int main(void){
// Your code here!
char a,b; cin >> a >> b;
if (a == b) cout << 'H' << endl;
else cout << 'D' << endl;
}
| a.cc:2:9: fatal error: atcoder/all: No such file or directory
2 | #include<atcoder/all>
| ^~~~~~~~~~~~~
compilation terminated.
|
s311018601 | p03777 | C++ | #include <bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------
int main(void){
// Your code here!
char a,b; cin >> a >> b;
if (a == b) cout << 'H' << endl;
else cout << 'D' << endl;
}
| a.cc:2:9: fatal error: atcoder/all: No such file or directory
2 | #include<atcoder/all>
| ^~~~~~~~~~~~~
compilation terminated.
|
s396902669 | p03777 | C++ | #include <iostream>
#include <string>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
if (a == "H")
cout << b << "\n";
else if (b == "H")
cout << "D" << "\n";
else
cout << "H" << "\n";
} | a.cc: In function 'int main()':
a.cc:8:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
8 | if (a == "H")
| ~~^~~~~~
a.cc:10:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
10 | else if (b == "H")
| ~~^~~~~~
|
s153095418 | p03777 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(){
char a,b;
cin >> a >> b;
if(b=="H")cout << a << endl;
else if(a=='H')cout << "D" << endl;
else cout << "H" << endl;
} | a.cc: In function 'int main()':
a.cc:8:7: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
8 | if(b=="H")cout << a << endl;
| ~^~~~~
|
s510062660 | p03777 | C | #include <bits/stdc++.h>
using namespace std;
int main() {
char a, b;
cin >> a >> b;
if (a == 'H') {
if (b == 'H') {
cout << "H" << endl;;
} else {
cout << "H" << endl;;
}
} else {
if (b == 'H') {
cout << "D" << endl;
} else {
cout << "H" << endl;;
}
}
}
| main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s429815236 | p03777 | C | #include <iostream>
using namespace std;
int main() {
char a, b;
cin >> a >> b;
if (a == 'H') {
if (b == 'H') {
cout << "H" << endl;;
} else {
cout << "H" << endl;;
}
} else {
if (b == 'H') {
cout << "D" << endl;
} else {
cout << "H" << endl;;
}
}
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s019367368 | p03777 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ll long long
signed main()
{
int a,b;
cin >> a >> b;
cout << (a=='H'&& b=='H' ? 'H': a=='H'&& b=='D' ? 'D' : a=='D'&& b=='H' ? 'D' : 'H')
} | a.cc: In function 'int main()':
a.cc:10:87: error: expected ';' before '}' token
10 | cout << (a=='H'&& b=='H' ? 'H': a=='H'&& b=='D' ? 'D' : a=='D'&& b=='H' ? 'D' : 'H')
| ^
| ;
11 | }
| ~
|
s238896740 | p03777 | C++ | #include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
int a, b;
cin >> a >> b;
if (a == 'H' && b =='H'){
cout << 'H' << endl;
}else if(a == 'H' && b == 'D'){
cout << 'D' << endl;
}else if (a == 'D' && b == 'H'){
cout << 'D' << endl;
}else if (a == 'D' && b == 'D')
cout << 'H' << endl;
}
}
| a.cc:20:1: error: expected declaration before '}' token
20 | }
| ^
|
s097507043 | p03777 | C++ | #include <bits/stdc++.h>
using namespace std;
//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
T r;
while (a)
r = b, b = a, a = r % a;
return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)
// vector
#define ALL(x) x.begin(), x.end()
// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
cout << a;
ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
cout << a << ' ';
}
int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n;
int x, y;
char ch;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
int main()
{
char a, b;
cin >> a >> b;
if (a =='H' && b == 'H')
cout << 'H';
if (a == ’H ’ && b == 'D')
cout << 'D';
if (a == 'D' && b == 'H')
cout << 'D';
if (a == 'D'&& b == 'D')
cout << 'H';
return 0;
}
| a.cc:81:12: error: extended character ’ is not valid in an identifier
81 | if (a == ’H ’ && b == 'D')
| ^
a.cc:81:15: error: extended character ’ is not valid in an identifier
81 | if (a == ’H ’ && b == 'D')
| ^
a.cc: In function 'int main()':
a.cc:81:12: error: '\U00002019H' was not declared in this scope
81 | if (a == ’H ’ && b == 'D')
| ^~
a.cc:81:14: error: expected ')' before '\U00002019'
81 | if (a == ’H ’ && b == 'D')
| ~ ^~
| )
|
s350168354 | p03777 | C++ | #include <bits/stdc++.h>
using namespace std;
//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
T r;
while (a)
r = b, b = a, a = r % a;
return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)
// vector
#define ALL(x) x.begin(), x.end()
// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
cout << a;
ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
cout << a << ' ';
}
int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n;
int x, y;
char ch;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
int main()
{
char a , b;
cin >> a >> b;
if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
return 0;
}
| a.cc:79:11: error: extended character ’ is not valid in an identifier
79 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:79:14: error: extended character ’ is not valid in an identifier
79 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:79:24: error: extended character ’ is not valid in an identifier
79 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:79:27: error: extended character ’ is not valid in an identifier
79 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:79:38: error: extended character ’ is not valid in an identifier
79 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:79:41: error: extended character ’ is not valid in an identifier
79 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:80:11: error: extended character ’ is not valid in an identifier
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:80:14: error: extended character ’ is not valid in an identifier
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:80:24: error: extended character ’ is not valid in an identifier
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:80:27: error: extended character ’ is not valid in an identifier
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:80:38: error: extended character ’ is not valid in an identifier
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:80:41: error: extended character ’ is not valid in an identifier
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:81:11: error: extended character ’ is not valid in an identifier
81 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:81:14: error: extended character ’ is not valid in an identifier
81 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:81:24: error: extended character ’ is not valid in an identifier
81 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:81:27: error: extended character ’ is not valid in an identifier
81 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:81:38: error: extended character ’ is not valid in an identifier
81 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:81:41: error: extended character ’ is not valid in an identifier
81 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:82:11: error: extended character ’ is not valid in an identifier
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:82:14: error: extended character ’ is not valid in an identifier
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:82:24: error: extended character ’ is not valid in an identifier
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:82:27: error: extended character ’ is not valid in an identifier
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:82:38: error: extended character ’ is not valid in an identifier
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:82:41: error: extended character ’ is not valid in an identifier
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc: In function 'int main()':
a.cc:79:11: error: '\U00002019H' was not declared in this scope
79 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^~
a.cc:79:13: error: expected ')' before '\U00002019'
79 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ~ ^~
| )
a.cc:80:11: error: '\U00002019H' was not declared in this scope
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^~
a.cc:80:13: error: expected ')' before '\U00002019'
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ~ ^~
| )
a.cc:80:38: error: '\U00002019D' was not declared in this scope
80 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^~
a.cc:81:11: error: '\U00002019D' was not declared in this scope
81 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^~
a.cc:81:13: error: expected ')' before '\U00002019'
81 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ~ ^~
| )
a.cc:82:11: error: '\U00002019D' was not declared in this scope
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^~
a.cc:82:13: error: expected ')' before '\U00002019'
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ~ ^~
| )
a.cc:82:38: error: '\U00002019H' was not declared in this scope
82 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^~
|
s580739441 | p03777 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
char a ,b,c;
cin a >> b ;
if ( a == 'H'){
c = b;
}
if ( a == 'D'){
if ( b == 'H'){
c = 'D';
}else c='H';
}
cout << c << endl;
} | a.cc: In function 'int main()':
a.cc:6:6: error: expected ';' before 'a'
6 | cin a >> b ;
| ^~
| ;
|
s339167407 | p03777 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
char a ,b,c;
cin a >> b ;
if ( a == 'H'){
c = b;
}
if ( a == 'D'){
if ( b == 'H'){
c = 'D'
}else c='H'
}
cout << c << endl;
} | a.cc: In function 'int main()':
a.cc:6:6: error: expected ';' before 'a'
6 | cin a >> b ;
| ^~
| ;
a.cc:12:12: error: expected ';' before '}' token
12 | c = 'D'
| ^
| ;
13 | }else c='H'
| ~
a.cc:13:16: error: expected ';' before '}' token
13 | }else c='H'
| ^
| ;
14 | }
| ~
|
s271642068 | p03777 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
char a,b;
cin >> a >> b;
if(a=='H'&&b=='H')cout << 'H' <<endl;
if(a=='D'&&b=='H')cout << 'D' <<endl;
if(a=='D'&&b=='D')cout << 'H' <<endl;
if(a=='H'&&b=='D')cout << 'D' <<endl;
else
} | a.cc: In function 'int main()':
a.cc:13:1: error: expected primary-expression before '}' token
13 | }
| ^
|
s000953240 | p03777 | C++ | #include<bits/stdc++.h>
using namespace std;
int main () {
char a, b;
cin >> a >> b;
cout << (a == b ? 'H' : 'D') << endl:
} | a.cc: In function 'int main()':
a.cc:6:39: error: expected ';' before ':' token
6 | cout << (a == b ? 'H' : 'D') << endl:
| ^
| ;
|
s904748801 | p03777 | C++ | #include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
//#define int long long ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) { //階乗
if (i == 0) return 1;
return (fact(i - 1)) * i;
}
int gcd(int a, int b) { //最大公約数
if (b == 0) return a;
return gcd(b, a % b);
}
int lcm(int a, int b) { //最小公倍数
return a * b / gcd(a, b);
}
int keta(int n) { //桁数を求める
if (n == 0) return 1;
int count = 0;
while (n != 0) {
n /= 10;
count++;
}
return count;
}
int ketasum(int n) { //各桁の和
int sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
/*-------------ここまで---------------------------------------------*/
//C++(GCC9.2.1)
/*signed*/int main(void) {
char a , b;
cin >> a >> b;
if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
return 0;
} | a.cc:85:13: error: extended character ’ is not valid in an identifier
85 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:85:16: error: extended character ’ is not valid in an identifier
85 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:85:26: error: extended character ’ is not valid in an identifier
85 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:85:29: error: extended character ’ is not valid in an identifier
85 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:85:40: error: extended character ’ is not valid in an identifier
85 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:85:43: error: extended character ’ is not valid in an identifier
85 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^
a.cc:86:13: error: extended character ’ is not valid in an identifier
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:86:16: error: extended character ’ is not valid in an identifier
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:86:26: error: extended character ’ is not valid in an identifier
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:86:29: error: extended character ’ is not valid in an identifier
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:86:40: error: extended character ’ is not valid in an identifier
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:86:43: error: extended character ’ is not valid in an identifier
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^
a.cc:87:13: error: extended character ’ is not valid in an identifier
87 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:87:16: error: extended character ’ is not valid in an identifier
87 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:87:26: error: extended character ’ is not valid in an identifier
87 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:87:29: error: extended character ’ is not valid in an identifier
87 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:87:40: error: extended character ’ is not valid in an identifier
87 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:87:43: error: extended character ’ is not valid in an identifier
87 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^
a.cc:88:13: error: extended character ’ is not valid in an identifier
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:88:16: error: extended character ’ is not valid in an identifier
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:88:26: error: extended character ’ is not valid in an identifier
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:88:29: error: extended character ’ is not valid in an identifier
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:88:40: error: extended character ’ is not valid in an identifier
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:88:43: error: extended character ’ is not valid in an identifier
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^
a.cc:42:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
42 | const int INF = 1e18 + 9;
| ~~~~~^~~
a.cc: In function 'int main()':
a.cc:85:13: error: '\U00002019H' was not declared in this scope
85 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ^~
a.cc:85:15: error: expected ')' before '\U00002019'
85 | if ( a == ’H ’ && b == ’H ’) cout << ’H ’;
| ~ ^~
| )
a.cc:86:13: error: '\U00002019H' was not declared in this scope
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^~
a.cc:86:15: error: expected ')' before '\U00002019'
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ~ ^~
| )
a.cc:86:40: error: '\U00002019D' was not declared in this scope
86 | if ( a == ’H ’ && b == ’D ’) cout << ’D ’;
| ^~
a.cc:87:13: error: '\U00002019D' was not declared in this scope
87 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ^~
a.cc:87:15: error: expected ')' before '\U00002019'
87 | if ( a == ’D ’ && b == ’H ’) cout << ’D ’;
| ~ ^~
| )
a.cc:88:13: error: '\U00002019D' was not declared in this scope
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^~
a.cc:88:15: error: expected ')' before '\U00002019'
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ~ ^~
| )
a.cc:88:40: error: '\U00002019H' was not declared in this scope
88 | if ( a == ’D ’ && b == ’D ’) cout << ’H ’;
| ^~
|
s184032846 | p03777 | Java | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if(a.equals(b)){
System.out.println("H");
}else{
System.out.println("D");
}
}
} | Main.java:9: error: int cannot be dereferenced
if(a.equals(b)){
^
1 error
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.