_清醒

0

0

1530

_清醒
1个月前
#include <iostream>
using namespace std;
int q[35][35];

int main (){
int n, m;
cin >> n >> m;
q[1][1] = 1;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if((i%2==0) && (j%2 == 0)) {q[i][j] = 0;continue;}
if(i==1 && j ==1) continue;
q[i][j] = q[i-1][j] + q[i][j-1];
}
}
//cout << q[1][1] << endl;
//cout << q[2][2] << endl;
cout << q[n][m];
}


_清醒
1个月前
#include <iostream>
using namespace std;
int main(){
string s;
cin >> s;
char now;
int i = 0;
while(i < s.size()){
now = s[i];
if(i + 1 < s.size() && s[i + 1] <= '9' && s[i + 1] >= '0'){
int amount = s[i + 1] - '0';
for(int j = 0; j < amount; j ++ )   cout << now;
i += 2;
}else{
cout << now;
i ++ ;
}
}
return 0;
}


_清醒
1个月前
//这里填你的代码^^
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~
#include <iostream>
using namespace std;

int main() {
long long n;
cin >> n;
while(n > 0) {
cout << n << " ";
n /= 2;
}
}


_清醒
8个月前
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010;
int q[N];
int gcd(int a, int b) {
return b? gcd(b, a%b) : a;
}
int main() {
int n;
cin >> n;
for(int i = 0; i < n; i ++) cin >> q[i];
sort(q, q+n);
int d = 0;
for (int i = 1; i < n; i ++ ) d = gcd(d, q[i] - q[0]);

if (!d) printf("%d\n", n);
else printf("%d\n", (q[n - 1] - q[0]) / d + 1);

return 0;
}


_清醒
8个月前
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=1e5+10;
int n,m,k;
LL a[2*MAXN];

int main(){
scanf("%d%d",&n,&m);
k=n+m+1;
for(int i=1;i<=k;i++) scanf("%lld",&a[i]);
LL sum=0;
if(!m){
for(int i=1;i<=k;i++) sum+=a[i];
printf("%lld\n",sum);
return 0;
}
sort(a+1,a+k+1);
sum+=a[k];sum-=a[1];m--;
for(int i=2;i<k;i++) sum+=abs(a[i]);
printf("%lld\n",sum);
return 0;
}


_清醒
8个月前
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int N = 100010, mod = 1000000009;

int n, k;
int a[N];

int main()
{
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i ++ ) scanf("%d", &a[i]);
sort(a, a + n);

int res = 1;
int l = 0, r = n - 1;
int sign = 1;
if (k % 2)
{
res = a[r -- ];
k -- ;
if (res < 0) sign = -1;
}
while (k)
{
LL x = (LL)a[l] * a[l + 1], y = (LL)a[r - 1] * a[r];
if (x * sign > y * sign)
{
res = x % mod * res % mod;
l += 2;
}
else
{
res = y % mod * res % mod;
r -= 2;
}
k -= 2;
}

printf("%d\n", res);

return 0;
}


_清醒
8个月前
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int n, s, cnt;
int a[500010];

int main()
{
scanf("%d%d", &n, &s);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);

sort(a, a + n);

double ave = s * 1.0 / n, cur_ave = ave, sum = 0;
for (int i = 0; i < n; i++)
{
if (a[i] <= cur_ave)
{
s -= a[i];
sum += (ave - a[i]) * (ave - a[i]);
cur_ave = s * 1.0 / (n - i - 1);//  当前平均值
}
else sum += (cur_ave - ave) * (cur_ave - ave);
}

printf("%.4lf", sqrt(sum / n));
return 0;
}



_清醒
8个月前
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 +10 ;
int q[N];
int main() {
int n;
cin >> n;
for(int  i = 0; i < n; i ++) cin >> q[i];
sort(q, q+n);
int mid = q[n/2];
int res = 0;
for(int i = 0;i < n;i ++) {
res += abs(q[i] - mid);
}
cout << res << endl;
}


_清醒
8个月前
#include <iostream>
using namespace std;
const int N = 100000;
int q[N];

int main() {
int n;
cin >> n;
for(int i = 0; i < n; i ++ )
cin >> q[i];

int res = 0;
for(int i = 0,j = 0; i < n; i ++) {
if(q[j] <= q[i]) {
res += q[i] - q[j];
j = i;
}
else if(q[j] > q[i]) {
j = i;
}
}
cout << res << endl;
}


_清醒
8个月前
#include<iostream>
using namespace std;
const int N=100010;
int a;
n[idx]=x;
}
n[idx]=x;
ne[idx]=ne[k];
ne[k]=idx++;
}
void remove(int k){
ne[k]=ne[ne[k]];
}

int main(){

cin>>a;
while(a--){
string op;
int k,x;
cin>>op;
if(op=="D")
{

cin>>k;
remove(k-1);
}
else if(op=="H")
{
cin>>x;
}
else if(op=="I"){
int k,x;
cin>>k>>x;