头像

蒟蒻-王善珑

啊没有的呢




离线:3天前


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

include[HTML_REMOVED]

using namespace std;
int main()
{
int a[1010],n,num=0;
cin>>n;
for(int i=1;i<=n;i)
{
cin>>a[i];
}
for(int i=2;i[HTML_REMOVED]a[i]&&a[i+1]>a[i]))
{
num
;
}
}
cout<<num;
return 0;
}



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

include[HTML_REMOVED]

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. 画图

include[HTML_REMOVED]

using namespace std;
const int N=110;
int p[N][N];
int n;
int main(){
cin>>n;
while(n–){
int x1,y1,x2,y2;
scanf(“%d%d%d%d”,&x1,&y1,&x2,&y2);
x1,y1;
p[x1][y1]+=1;
p[x2+1][y1]-=1;
p[x1][y2+1]-=1;
p[x2+1][y2+1]+=1;
}
int ans=0;
for(int i=1;i<=101;i)
for(int j=1;j<=101;j
){
p[i][j]+=p[i-1][j]+p[i][j-1]-p[i-1][j-1];
if(p[i][j]) ans++;
}
cout<<ans;
return 0;
}



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

import java.util.Scanner;
public class Main{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
int n,last = 0,ans = 0;
while(true)
{
n = in.nextInt();
if(n==2) {last +=2;ans += last;}
else if(n==1) {ans+=1;last = 0;}
else break;
}
System.out.println(ans);
}
}



活动打卡代码 AcWing 445. 数字反转

include [HTML_REMOVED]

signed main() {
int n; std::cin >> n; int ans = 0;
while(n) ans = (ans<<3)+(ans<<1)+n%10, n /= 10;
std::cout << ans << std::endl;
}



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

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 510;

int n;
int a[N][N];

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

    for (int i = 2; i <= n * 2; i ++ )
    {
        if (i % 2)
        {
            for (int j = 1; j < i; j ++ )
                if (j >= 1 && j <= n && i - j >= 1 && i - j <= n)
                    printf("%d ", a[j][i - j]);
        }
        else
        {
            for (int j = i - 1; j; j -- )
                if (j >= 1 && j <= n && i - j >= 1 && i - j <= n)
                    printf("%d ", a[j][i - j]);
        }
    }

    return 0;
}


活动打卡代码 AcWing 449. 质因数分解

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for (int p = 2; ; p ++ )
        if (n % p == 0)
        {
            cout << n / p << endl;
            break;
        }
    return 0;
}


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

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    string num;
    cin >> num;
    int sum = 0;
    for (auto c: num) sum += c - '0';

    string str = to_string(sum);
    string name[] = {
        "zero", "one", "two", "three", "four",
        "five", "six", "seven", "eight", "nine"
    };

    for (auto c: str)
        cout << name[c - '0'] << ' ';
    return 0;
}


活动打卡代码 AcWing 496. 机器翻译

#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 1010;

int n, m;
bool st[N];

int main()
{
    cin >> m >> n;

    queue<int> q;
    int res = 0;
    for (int i = 0; i < n; i ++ )
    {
        int x;
        scanf("%d", &x);
        if (!st[x])
        {
            if (q.size() >= m)
            {
                st[q.front()] = false;
                q.pop();
            }
            q.push(x);
            st[x] = true;
            res ++ ;
        }
    }

    cout << res << endl;

    return 0;
}\


活动打卡代码 AcWing 441. 数字统计

#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
int main()
{
    int l, r;
    cin>>l>>r;
    int res = 0;
    for (int i = l; i <= r; i ++ )
        for (int j = i; j; j /= 10)
            if (j % 10 == 2)
                res ++ ;
    cout<<res;
    return 0;
}