Codeforces #362 div2 prob697 没有题解= =

本文提供了三道编程题目的解答思路及代码实现:Pineapple Incident题通过判断位置关系得出结果;Barnicle题实现了科学计数法的格式转换;Lorenzo Von Matterhorn题利用了树状数组进行区间更新和查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这套题有点懒得写题解了,,,看代码基本上都能看懂,,,,

697A:Pineapple Incident

#include <cstdio>

int t, x, s;

int main () {
    scanf("%d %d %d", &t, &s, &x);
    if (x < t) printf("NO");
    else if (x == t) printf("YES");
    else if (x > t && x < t + s) printf("NO");
    else {
        int cur = (x - t) % s;
        if (cur == 0 || cur == 1) printf("YES");
        else printf("NO");
    }
    return 0;
}

697B:Barnicle:

#include <cstdio>
#include <cstring>
#include <algorithm>

char s[1010000];
bool f = 0; // f = 1 means a is real
int cur = 0;
int cure = 0;
int b;

int main () {
    gets(s);
    int len = strlen(s);
    for (int i = 0; i < len; i++) {
        if (s[i] == '.') {
            f = 1;
            cur = i;
        }
        if (s[i] == 'e') {
            cure = i;
        } 
    }
    b = atoi(&s[cure+1]);
    if (b == 0) {
        if (s[cur+1] == '0' && s[cur+2] == 'e') {
            for (int i = 0; i < cur; i++) printf("%c", s[i]);
            exit(0);
        }
        for (int i = 0; i < cure; i++) printf("%c", s[i]);
        exit(0);
    }
    // printf("%d", b);
    if (cure - cur - 1 > b) {
        int k = cur + b;
        int ttt = k;
        for (int i = 0; i <= k; i++) 
            if (s[i] != '0' && s[i] != '.') {
                ttt = i;
                break;
            }
        for (int i = ttt; i <= k; i++) 
            if (s[i] >= '0' && s[i] <= '9') printf("%c", s[i]);
        printf(".");
        for (int i = k + 1; i < cure; i++) printf("%c", s[i]);
    } else {
        int ttt = 0;
        for (int i = 0; i < cure; i++) {
            if (s[i] != '0' && s[i] != '.') {
                ttt = i;
                break;
            }
        }
        for (int i = ttt; i < cure; i++) 
            if (s[i] >= '0' && s[i] <= '9') printf("%c", s[i]);
        int k = b - cure + cur + 1;
        while (k--) printf("0");
    }
    return 0;
}

697C:Lorenzo Von Matterhorn:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>

std :: map<long long, long long> mp;
int q;
int od;
long long x, y, z;


void change(long long x, long long y, long long z) {
    if (x < y) std :: swap(x, y);
    while (x != y) {
        mp[x] += z;
        x = x >> 1;
        if (x < y) std :: swap(x, y);
    }
}

long long xfind(long long x, long long y) {
    long long ans = 0;
    if (x < y) std :: swap(x, y);
    while (x != y) {
        ans += mp[x];
        x = x >> 1;
        if (x < y) std :: swap(x, y);
    }
    return (ans);
}

int main () {
    scanf("%d", &q);
    for (int i = 1; i <= q; i++) {
        scanf("%d %I64d %I64d", &od, &x, &y);
        if (od == 1) {
            scanf("%I64d", &z);
            change(x, y, z);
        } else {
            printf("%I64d\n", xfind(x, y));
        }
    }

    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值