头像

据东风

NBS




离线:2个月前


最近来访(1)
用户头像
小朋友没有武德

活动打卡代码 AcWing 104. 货仓选址

据东风
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;
}



活动打卡代码 AcWing 3257. 跳一跳

据东风
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;
}



活动打卡代码 AcWing 3227. 折点计数

据东风
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;
}





活动打卡代码 AcWing 3232. 最大波动

据东风
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;
}



活动打卡代码 AcWing 3203. 画图

据东风
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;
}

作者:Hasity
链接:https://www.acwing.com/solution/content/35930/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


活动打卡代码 AcWing 3208. Z字形扫描

据东风
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;
}




活动打卡代码 AcWing 1477. 拼写正确

据东风
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;
}

作者:小叶小叶风情不解
链接:https://www.acwing.com/solution/content/10757/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。




据东风
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;
}



活动打卡代码 AcWing 666. 三角形类型

据东风
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;
}