NBS

1029

8个月前

#include [HTML_REMOVED]
using namespace std;
typedef long long ll;
ll n,ans;
const ll N=1e5+1e4;
ll a[N];
signed main()
{
cin>>n;
for(ll i=1;i<=n;i)cin>>a[i];
sort(a+1,a+n+1);
for(ll i=1;i<=n/2;i
)ans+=(a[n-i+1]-a[i]);
cout<<ans;
return 0;
}


8个月前

# include [HTML_REMOVED]

using namespace std;
typedef long long ll;
ll n,ans;
const ll N=1e5+1e4;
ll a[N];
signed main()
{
cin>>n;
for(ll i=1;i<=n;i)cin>>a[i];
sort(a+1,a+n+1);
for(ll i=1;i<=n/2;i
)ans+=(a[n-i+1]-a[i]);
cout<<ans;
return 0;
}

8个月前
#include<iostream>

using namespace std;
int ans;
int main(){
int n,sum=0;
while(cin>>n,n){
if(n==1) sum=1;
else if(sum==1)sum=2;
else sum+=2;
ans+=sum;
}
cout<<ans;
return 0;
}



8个月前
#include<cstdio>
using namespace std;
const int N = 10000;
int n;
int ans=0;
int a[N << 1];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1+1;i<=n-1;i++)
{
if(a[i]>a[i+1]&&a[i]>a[i-1] || a[i]<a[i-1]&&a[i]<a[i+1])
ans++;

}
printf("%d ",ans);
return 0;
}



8个月前
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int a[1010];
int ans = 0;
cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i];
for(int i = 1; i < n; i ++)
{
ans = max(ans, abs(a[i + 1] - a[i]));
}
cout << ans;
}



8个月前
#include <iostream>
using namespace std;

const int N = 110;

bool g[N][N];//地图，初始时，各个点为 0

int main()
{
int n;
cin >> n;
while(n--)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;

for(int i = x1; i < x2; i++)
{
for(int j = y1; j < y2; j++)
{
g[i][j] = 1;//涂颜色
}
}
}

int res = 0;

for(int i = 0; i < 110; i++)
{
for(int j = 0; j < 110; j++)
{
res += g[i][j];//统计颜色
}
}

cout << res;
}



8个月前
#include <iostream>
using namespace std;

const int N = 510;
int a[N][N];

int main(){

ios::sync_with_stdio(false);cin.tie(0);

int n;
cin >> n;

for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
cin >> a[i][j];

int x = 0, y = 0;
bool flag = true;

while(x != n || y != n){

if(x < n && y < n)
cout << a[x][y] << ' ';

if(flag) x--, y++;
else x++, y--;

if(x < 0) {
x = 0;
flag = !flag;
}
if(y < 0){
y = 0;
flag = !flag;
}

}
return 0;
}



8个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

string table[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};

int main()
{
string a;
cin >> a;
if(a == "0") //特判,不然遇到0会段错误
{
cout << "zero";
return 0;
}
long long sum = 0;
int ans[10000];
int len = a.length();
for (int j = 0; j < len; j++)
{
sum += (a[j] - '0');
}
int i = 0;
while(sum)
{
ans[i] = sum % 10;
sum /= 10;
i++;
}
i--;
while(i)
{
cout << table[ans[i]] << " ";
i--;
}
cout << table[ans[i]]; //末尾不能有空格
return 0;
}



8个月前

# include[HTML_REMOVED]

using namespace std;
double a,b,c;
int main()
{
cin>>a>>b>>c;
if(a[HTML_REMOVED]=b+c)
{
cout<<”NAO FORMA TRIANGULO”;
}
else
{
if(aa==bb+cc)
{
cout<<”TRIANGULO RETANGULO”<[HTML_REMOVED]b
b+cc)
{
cout<<”TRIANGULO OBTUSANGULO”<<endl;
}
if(a
a<bb+cc)
{
cout<<”TRIANGULO ACUTANGULO”<<endl;
}
if(a==b&&b==c)
{
cout<<”TRIANGULO EQUILATERO”<<endl;
}
if((a==b&&b!=c&&a!=c)||(a!=b&&b==c&&a!=c)||(a!=b&&b!=c&&a==c))
{
cout<<”TRIANGULO ISOSCELES”<<endl;
}
}
return 0;
}

8个月前
#include<bits/stdc++.h>
using namespace std;
double a,b,c;
int main()
{
cin>>a>>b>>c;
if(a<b)
{
swap(a,b);
}
if(a<c)
{
swap(a,c);
}
if(b<c)
{
swap(b,c);
}
if(a>=b+c)
{
cout<<"NAO FORMA TRIANGULO";
}
else
{
if(a*a==b*b+c*c)
{
cout<<"TRIANGULO RETANGULO"<<endl;
}
if(a*a>b*b+c*c)
{
cout<<"TRIANGULO OBTUSANGULO"<<endl;
}
if(a*a<b*b+c*c)
{
cout<<"TRIANGULO ACUTANGULO"<<endl;
}
if(a==b&&b==c)
{
cout<<"TRIANGULO EQUILATERO"<<endl;
}
if((a==b&&b!=c&&a!=c)||(a!=b&&b==c&&a!=c)||(a!=b&&b!=c&&a==c))
{
cout<<"TRIANGULO ISOSCELES"<<endl;
}
}
return 0;
}

`